'Why am I getting a namespace identifier error?

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?



Solution 1:[1]

You did not expose many details but my hunch is that you use a C compiler for your C++ program. There are no namespaces in C.

I could produce similar messages with this program:

namespace test {
}

Output:

$ gcc test.c
test.c:1:1: error: unknown type name 'namespace'
 namespace test {
 ^
test.c:1:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{
' token
namespace test {
            ^

Ideone link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1