Why am I getting a namespace identifier error?

user3729617 picture user3729617 · Jun 30, 2014 · Viewed 7.1k times · Source

I am using Keil uVision and I keep getting this error:

C:\Keil_v5\ARM\ARMCC\bin\..\include\rw/_defs.h(781): error:  #20:
    identifier "namespace" is undefined

What could lead to this error? Isn´t namespace automatically defined?

Answer

Clifford picture Clifford · Jun 30, 2014

It looks like you are using C compilation for C++ code - check the compiler options.

In C++ namespace is a reserved word, but not in C, so the compiler will try to interpret it as an identifier rather than a keyword - which will then of course make no sense syntactically to a C compiler.