I'm getting this compilation error with the following code:
error C2143: syntax error : missing ';' before 'using'
#include <iostream>
#include <iomanip>
#include <fstream>
#include <st开发者_如何学运维ring>
#include "s.h"
using namespace std;
How is this possible? How can it be fixed?
"s.h"
might contain a class declaration that wasn't terminated with a ;
When you include a header, the C preprocessor puts substitutes header's contents in in-line, so if you look at s.h
you will probably find something unterminated by ;
The error is in your s.h
. In C++, #include
is only a text insertion mechanism, so if the end of a header file contains an error, you might get the error in a file that #include
s the faulty file.
It could also be that the s.h isn't a C++ header but a C header which is not declared extern C try to replace your
#include "s.h"
with
#ifdef __cplusplus
extern "C"
{
#endif
#include "s.h"
#ifdef __cplusplus
}
#endif
you could also fix this in the header file itself.
精彩评论