The error of C + + compiler is as follows:
error: expected class-name before ‘{’ token
When deriving a class, you need to confirm whether it contains the header file of the base class.
If the header file of the base class is included, an error is still reported. As mentioned above, check the header file contained in the base class header file.
For example, all the information about an error is as follows:
aarch64-himix100-linux-g++ -c ./src/base.cpp ./src/host.cpp ./src/main_test.cpp ./src/mcu.cpp ./src/uart1.cpp
In file included from ./src/../include/main_test.h:6:0,
from ./src/../include/base.h:6,
from ./src/base.cpp:1:
./src/../include/uart1.h:10:1: error: expected class-name before ‘{’ token
{
^
make: *** [main_test.o] Error 1
There are base classes in the base. H file. Uart1. H is the class to be derived. But look at all the above error information, it appears from the sixth line of base. H. Find line 6, which is the header file of the main function (test program).
Put the header file in line 6 base.cpp It’s OK.
In fact, the above situation should not appear in base. H and base.cpp The header file of the test file should not appear in.
Put the header files (such as # include & lt; pthread. H & gt;) in the corresponding header files (such as base. H).
When testing, you only need to include the base. H file to test the functions in the base.
Read More:
- Syntax error on token “eat”, identifier expected after this token
- error: expected unqualified-id before ‘.’ token
- syntax error on token “catch”,Identifier expected
- Line 1: error: class, interface, or enum expected [in MainClass.java]
- [Solved] Scala signature package has wrong version expected: 5.0 found: 5.2 in package.class
- About writing [if] and [else] statements in JSP, Syntax error on token “else”, delete this token
- Token bucket implementation with adaptive token generation rate
- Syntax error on token “}“, delete this token
- Error c2011: “a certain class”: redefinition of “class” type
- The shell runs the class file and imports the jar package that the class depends on
- Expected unqualified ID before string constant
- Problems encountered after Maven installation or upgrade: could not find or load main class org.codehaus.plexus .class…..
- JWT and token + redis scheme of spring security
- syntax error near unexpected token `then’ problem solution
- Parsing error: Unexpected token
- Strange exception 001: invalid or unexpected token
- After SAP Spartacus successfully logs in, does the request base site need access token
- Passwd: authentication token manipulation error in Linux