Devlogs
my latest discovery is that gcc in linux does not prepend underscore at the beginning of the names of funcitons, while windows port of gcc compiler does that.
1 _main: 2 pushl %ebp 3 ... |
linux : gcc -S ble.c
1 main: 2 pushl %ebp 3 ... |
we can force gcc to add underscore using -fleading-underscore option, but this isnt good solution (try it yourself, or read gcc manual).
absence of underscore at the beginning of the name is important when you are trying to use code written and compiled under windows with gcc, or when you write assembler code and compile it with NASM (like in my previous post), this is also way how ive discovered this :) to use function that had been written in assembler and compiled with NASM in my c code (gcc in cygwin, borland) i had to declare it (in asm source) with underscoped name. because both gcc in cygwin and borland expects functions written in c to be preceded with underscore. but when i've tried to compile the same code with gcc under linux i got linker error (underscore)
to use the same assembler code in windows and linux i had to declare function with leading underscore (in linux), or to use asm() keyword to specify the name to be used in asm code (gcc manual page 281).
i think, the best solution is to add defines so that functions can be imported properly (with underscore) but used in code without it.
GCC under linux by default does not add prepend uderscore at the beginning of the function name.
No comments as yet. Be first to comment.