I'm currently having a small compilation problem with an enum.
In the C header file "stack.h" I have the following :-
- Code: Select all
enum boolean {false, true};
File "stack.h" is included in the (main) C++ file "test_stack.cpp" using the following :-
- Code: Select all
#include "stack.h"
When I compile "test_stack.cpp" using "g++ -Wall -g test_stack.cpp -o test_stack" I get the following error messages :-
In file included from test_stack.cpp:5:0:
stack.h:8:10: error: expected identifier before ‘false’
stack.h:8:10: error: expected ‘}’ before ‘false’
stack.h:8:10: error: expected unqualified-id before ‘false’
stack.h:8:21: error: expected declaration before ‘}’ token
To be clear, #include "stack.h" occurs on line 5 of "test_stack.cpp".
Does anyone know if a C++ program including a C header is likely to lead to just this kind of error message ? I would have thought that, as C++ is a superset of C, this would not be the case.
Also, I just don't see anything wrong with the enum. I've tried changing boolean to "truth" and then "valid". (I wondered if the fact that bool is a keyword in C++ was the problem.) A re-compilation in each case merely resulted in the displaying of the same error messages.
Thanks in advance,
Stuart