[okl4-developer] Cannot use the C library with C++?

Tomas Hruby thruby at cs.otago.ac.nz
Tue Oct 7 18:58:18 EST 2008


Hi Alex,

On Tue, Oct 07, 2008 at 04:37:38PM +0900, Alexandre Courbot wrote:
> Hello everybody,
> 
> I'm currently trying to port a C++ (well, C with classes actually)
> written root server to OKL4 2.1.1-patch9. My problem is that it looks
> like the C library does not like being parsed by the C++ compiler.
> Consider the following example:
> 
> extern "C" {
> #include <stdio.h>
> }
> 
> int main()
> {
>         printf("Hello, world!\n");
>         return 0;
> }
> 
> After integrating it as a separate project and running the builder, I obtain:
> 
> $ ./tools/build.py machine=ia32_pc99 project=arc verbose_str=1
> scons: Reading SConscript files ...
> architecture ia32 is not yet supported by libcompat.
> architecture ia32 is not yet supported by libcompat.
> scons: done reading SConscript files.
> scons: Building targets ...
> /opt/okl/Linux-i386/stow/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-g++
> -Wall -Wredundant-decls -Wundef -Wpointer-arith -Wno-uninitialized
> -Werror -O2 -nostdlib -nostdinc -fno-builtin -g -fno-exceptions
> -fomit-frame-pointer -finline-limit=99999999 -DCONFIG_CPU_IA32_I686
> -DCONFIG_CPU_IA32_I686 -DARCH_IA32 -DMACHINE_IA32_PC99 -DENDIAN_LITTLE
> -DWORDSIZE_32 -DKENGE_L4_ROOTSERVER -DCONFIG_MAX_THREAD_BITS=10
> -D__L4_ARCH__=ia32 -DL4_ARCH_IA32 -DCONFIG_USER_MUTEXES=1
> -DTHREAD_SAFE -Ibuild/l4_rootserver/include
> -Ibuild/l4_rootserver/object/arc/include arc/src/test2.cc -c -o
> build/l4_rootserver/arc/object/src/test2.o
> In file included from build/l4_rootserver/include/atomic_ops/atomic_ops.h:218,
>                  from build/l4_rootserver/include/mutex/mutex.h:69,
>                  from build/l4_rootserver/include/stdio.h:75,
>                  from arc/src/test2.cc:2:
> build/l4_rootserver/include/atomic_ops/arch/atomic_ops.h: In function
> `okl4_atomic_plain_word_t
> okl4_atomic_dec_return(okl4_atomic_word_t*)':
> build/l4_rootserver/include/atomic_ops/arch/atomic_ops.h:324: warning:
> passing negative value `-0x000000001' for converting 2 of
> `okl4_atomic_plain_word_t okl4_atomic_add_return(okl4_atomic_word_t*,
> okl4_atomic_plain_word_t)'
> scons: *** [build/l4_rootserver/arc/object/src/test2.o] Error 1
> scons: building terminated because of errors.
> 
> This is just a warning, but the builder does not let it go. Now if
> only I knew how to fix it or how to disable the -Werror flag of the
> compiler... :) Would someone have a pointer for this?

You can tell gcc not to treat some warnings as errors using -Wno-error
option. -fdiagnostics-show-option tells you which one you need to turn
off. See man gcc for all the options. You could also remove the
-Werror option, search for CC_WARNINGS in tools/toolchains.py

			T.



More information about the Developer mailing list