g++ - Compiler flag to reveal functions like strdup -


i've been given starter code project have complete in class i'm taking. code compiles fine on university computers when try compile code on own computer errors due function call strdup. can gather caused because strdup not iso c99 function (https://bugzilla.redhat.com/show_bug.cgi?id=130815). how should go getting code compile? i'd imagine need throw in additional compiler flags i'm not sure ones. in case need info ran g++ -v, here output:

using built-in specs. target: x86_64-linux-gnu configured with: ../src/configure -v --with-pkgversion='ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/readme.bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu thread model: posix gcc version 4.4.3 (ubuntu 4.4.3-4ubuntu5)  

the answer of seth correct. if doesn't work you, there possibility pass -std=gnu99 compiler option g++ (it automatically defines common test macros).

be sure add options @ end of command line, because later options overwrite newer ones!

here test macro requirements gnu glibc (from manpage):

       since glibc 2.12:            _svid_source || _bsd_source || _xopen_source >= 500 ||            _xopen_source && _xopen_source_extended ||            _posix_c_source >= 200809l        before glibc 2.12:            _svid_source || _bsd_source || _xopen_source >= 500 ||            _xopen_source && _xopen_source_extended 

i don't know why posix >= 200809l required, since manpage says conforms posix.1-2001.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -