Jonas Maebe wrote 24 lines
On 07 Sep 2008, at 14:35, Koenraad Lelong wrote:
> Google helped me understand the "volatile" keyword, but is there a
> Pascal alternative ?
No. FPC is at this time unlikely to perform any optimisations on pointer
or global variables accesses that would be inhibited by making them
"volatile" though.
> The "static inline" is more difficult to understand.
Just declare them as regular functions (with or without inline). It's
C's way of doing cross-module inlining:
a) the code has to be available in the header file, so the C compiler
has the C code available to inline when the function is called
b) if you declare the same function more than once, you are going to get
multiple symbols with the same name and these will clash at link time.
Therefore such inline functions in headers (which are almost always
included in more than one source file) have to be declared static, as
this makes these symbols private to that particular file.
Jonas
What I made of the h-file you can see in the archive. This compiles fine, both on i386-linux and arm-linux. But when I compile the testprogram for arm-linux I get this :
....
Searching file /opt/arcom/bin/arm-linux-ld... found Using util /opt/arcom/bin/arm-linux-ld
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `getpagesize'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `getenv'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `malloc'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `open'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `mmap'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `printf'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `printf'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `free'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `printf'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_open':
: undefined reference to `printf'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_close':
: undefined reference to `munmap'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_close':
: undefined reference to `close'
/opt/arcom/bin/../arm-linux/lib/libdevmem.a(libdevmem.o): In function `libdevmem_close':
: undefined reference to `free'
testdevmem.pas(29,1) Error: Error while linking
testdevmem.pas(29,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
I think I'm missing some file to link in, but I think I included every path. I use make.sh to know exactly what is included and what not, to try to debug this.
The original c-sample-application needs to statically link in the library. And I don't have the source of libdevmem, only the h-file.
fpc is 2.2.2rc2. I know 2.2.2 is out but I need time to test if it's ok to use it for my arm-system.
Thanks for any hints,
Koenraad Lelong.