On Fri, Feb 15, 2013 at 10:16:11PM +0100, Stefan Weil wrote: > It looks like most (but not all) versions of gcc emit built-in code > for ffs() even for compilations without optimisation. I have to provide > additional compiler options (e.g. -fno-builtin-ffs) to get a real > function call. > Only then I get the linker errors which you see. > > Obviously your compiler behaves different (or did you add extra > compiler options?). > > Try this short test.c code: > > int ffs(unsigned n); > int main(int argc, char *argv[]) > { > return ffs(argc); > } > > On Debian, I compiled and tested like this: > > amd64-mingw32msvc-gcc -c -g -O0 test.c > amd64-mingw32msvc-nm test.o > > There is no ffs function call in the resulting binary. > > If your compiler creates a function call, we have to know > why and whether there is a simple rule which versions of > gcc behave like that. If there is no simple rule, we need > a configure check.
A configure check would require that a compiler either creates always a function call, or never. I'm not sure if you can rely on that. Kevin