The man page for mmap on my machine says:
#include <sys/mman.h>
void *mmap(void *addr, size_t len, int prot, int flags,
int fildes, off_t off);
Some man page viewers, such as Emacs, convert the include statement into a hyperlink, allowing me to view /usr/include/sys/mman.h, which really helpful.
Is there any way I can jump to the source code itself of the function being documented (from the man page)?
Related
I used AutoHotKey recently, where I made a hotstring which would create a piece of code so that I can increase my productivity.
Here is the hotstring:
::basic::#include <iostream> int main(){}
But the output is:
#include <iostream> int main()
This script didn't include the curly braces I reqiured.
So, I want this to run perfectly.
Try:
::basic::#include <iostream> int main(){{}{}}
Can someone please explain to me what this means. (I've bolded the specific part in question).
The "Start VPN" field – in this case, 0x37D9BD30 – indicates the starting virtual page number. This must be converted to an actual address, by multiplying it by the page size. You can use the ? (Evaluate Expression) command to multiply this value by 0x2000, which is the page size for the Itanium-based machine the example comes from.
kd> ? 37d9bd3e*2000
Evaluate expression: 7676040298496 = 000006fb`37a7c000
Then the size of the range can be converted to bytes:
kd> ? 37d9bd3e-37d9bd30+1 <-- computes the number of pages
Evaluate expression: 15 = 00000000`0000000f
kd> ? f*2000
Evaluate expression: 122880 = 00000000`0001e000
So ExplorerFrame.dll starts at address 0x000006Fb37A7C000 and is 0x1E000 bytes large. You can load its symbols with:
kd> .reload /f ExplorerFrame.dll=6fb`37a7c000,1e000
The page size depends on the processor. Calling GetSystemInfo() [MSDN] gives you the page size in the field SYSTEM_INFO.dwPageSize. Wikipedia provides code that does it:
#include <stdio.h>
#include <windows.h>
int main(void) {
SYSTEM_INFO si;
GetSystemInfo(&si);
printf("The page size for this system is %u bytes.\n", si.dwPageSize);
return 0;
}
For the possible page sizes, refer to an Intel CPU manual.
x86 CPUs may have 4k (most common), 2M (PAE supported) or 4M (no PAE support)
x64 CPUs may have 4k (most common), 2M or even have 1G pages. It does not have 4M, since all x64 CPUs support PAE
Itanium may have 4k, 8k, 64k, 256k, 1M, 4M, 16M or 256M pages
I am working with C++ in org babel and would like to know how to format the includes so that I can list more than one.
Here's what I'm trying (that fails)
#+BEGIN_SRC C++ :includes <cstdio> :includes <iostream> :includes <string>
using namespace std;
printf("Hello ");
cout << "world\n";
#+END_SRC
In this case both printf and cout are undeclared in this scope. I can drop the unnecessary :includes <string> from the headers and the cout doesn't kick up an error, so it seems like only the last :includes counts. I have tried loading multiple includes into the same line using nothing, commas and spaces as delimiters and I always get an error about extra tokens at the end of the include directive. I have also tried using :includes+ in case that worked on the header line, but it didn't.
I'm fairly certain that what I'm trying to do should be possible because it says in the documentation that
:includes
(C & CC+ only) accepts either a single string name, or a list of names of files to #include in the execution of the code block
Org-version: 8.2.7-4-g880362-elpa
EDIT:
It's worth noting that other header arguments can just be strung together (i.e. :results raw drawer will produce unformatted results in a drawer), so there's a decent chance that this is a bug. Using :include <cstdio> <iostream> produces a compiler error that there's an extra token at the end of the #include <cstdio> line.
EDIT 2:
Turns out it's actually a bug in org, so it's been submitted.
After some experimenting, during which I noticed that some error messages look fairly lispy, and using the superficial knowledge I have of Lisp, I found the answer:
#+begin_src C++ :includes '("<math.h>" "<iostream>" "<algorithm>")
// Freely use symbols from those headers
#+end_src
Another issue that I'm having is that I can only get it to execute if I capitalize C++ but I only get syntax highlighting if I use minuscules ("c++"). Pure joy.
I am new to the site, and this looks like it may be a place to get some tips and help if any.
I am learning about "C calling Fortran subroutine", I have knowledge with C but not too much with Fortran.
Plus side: I've looked at some examples, and was able to compile a few.
Negative side: I am somewhat lost. I have a main program which can be designed using C or Fortran 90, and print_matrix.f and print_matrix.c.
Within the main.c program,
- populate array of 1-9 of a matrix size 3 by 3
- call the c function
- call the fortran subrountine
I already have the populated side(it may not be accurate), but I am stuck on the subrountine. The output of fortran and C has to be the same which will output through the print_matrix.f90 and print_matrix.c using makefile. I need help with the calling subrountine part, I just don't know where to begin with that :(
I just need help, any will be appreciated.
Honestly, it's a little hard to tell exactly what your problem is. But here's an example that works on my linux machine:
callf.c:
#include<stdio.h>
int main(int argc, char **argv) {
int i=0;
increment_(&i);
printf("%d\n",i);
return;
}
increment.f90:
subroutine increment(n)
integer n
n=n+1
return
end subroutine
Compiled with:
gcc -c callf.c
gfortran -c increment.f90
gcc callf.o increment.o -lgfortran
Result:
> ./a.out
1
The two hard parts are 1) getting the exact name of the function call and 2) knowing what flags are needed to link the two codes. Re: 1) I knew to use "increment_" because, after compiling my FORTRAN code, I ran the "nm" utility on increment.o and found the name of the object was "increment_". On some systems, you might see "INCREMENT", "_increment", or all sorts of other things. Re: 2) Information should be available for whatever compiler you are using. It varies alot.
I configured my cedet almost the same with http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html.
Thanks alexott , most of the time it works well, but I found that it can not well parse the tm struct in /usr/include/time.h.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void){
struct tm times;
FILE file;
}
When using M-x semantic-ia-fast-jump, the struct FILE is correct, but semantic finds the struct tm in wchar.h, not in time.h.
The problem seems to be there is a forward declaration in wchar.h for the struct tm.
In my copy of time.h, it appears that the symbol __BEGIN_NAMESPACE_STD is showing up in front of the struct declaration, and is befuddling the parser. You can fix that quickly by just adding that and __END_NAMESPACE_STD to the variable semantic-lex-c-preprocessor-symbol-map as mapping to empty. Then delete your semanticdb cache files (in ~/.semanticdb) related to time.h, or just everything in /usr/include, and restart emacs. time.h should get reparsed, and things should work ok for time.h after that... unless you want to use std::tm or something.