0

I get the following when trying to check a header file;

-*- mode: compilation; default-directory: "~/devel/projects/SHARED/" -*-
Compilation started at Wed Feb 15 16:06:41

gcc -fshow-column -fno-diagnostics-show-caret -fno-diagnostics-show-    option -iquote /home/micke/devel/projects/SHARED/ -Wall -Wextra -I ../SHARED -I ../Shared_Memory -I ../IDL -I /usr/local/cppenv/CppEnv/linux/ace/5.4/ACE_wrappers -I /usr/local/cppenv/CppEnv/linux/ace/5.4/ACE_wrappers/TAO -I /usr/local/cppenv/CppEnv/linux/roguewave -I /usr/local/cppenv/CppEnv/linux/boost/1.38.0/include/boost-1_38 -x c -S -o /dev/null - < /home/micke/devel/projects/SHARED/globtypes.h
<stdin>:39:1: error: unknown type name ‘namespace’
<stdin>:40:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
<stdin>:71:1: error: unknown type name ‘namespace’
<stdin>:72:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
<stdin>:91:1: error: unknown type name ‘namespace’
<stdin>:92:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
<stdin>:127:45: error: unknown type name ‘e_ivr_app_state’
<stdin>:156:1: error: unknown type name ‘namespace’
<stdin>:157:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
<stdin>:485:19: warning: ‘CAUSE_OVERFLOW’ initialized and declared ‘extern’

Compilation exited abnormally with code 1 at Wed Feb 15 16:06:41

The code is C++ and not C but the fact that gcc doesn't recognize the keyword 'namespace' leads me to belive gcc is compiling for C and not C++. I also had a warning earlier that cc1 thinks the parameter -std=c++98 is invalid for C but not for C++, I removed the parameter from the configuration of Flycheck in my .emacs. But it also leads me to the same conclusion that gcc is compiling C and not C++. How do I configure Flycheck so that gcc compiles C++ and not C?

  • 1
    I suspect this happens because the header file is opened in c-mode, not c++-mode. Does M-x c++-mode make the problem go away? If so, the answers to this question might help to make Emacs switch to C++ mode automatically. – legoscia Feb 15 '17 at 16:57
  • Try to use g++ for compile/link cpp projects/files, since gcc is only for standard C language. – Ian Feb 16 '17 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.