Reputation: 185
I am trying to reuse Apple's Speak Here sample code in my own iPhone app. I downloaded and compiled the project with no problems, so I then added some of the files to my own application. When I try to compile my own application, the compiler gives me
MeterTable.h:54: error: syntax error before 'MeterTable'
The relevant code is:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
class MeterTable // line 54
{
public:
It looks kind of like xcode isn't recognizing MeterTable.h and MeterTable.mm as C++ files. I've checked File>>GetInfo for MeterTable.mm, though, and it lists filetype as sourcecode.cpp.cpp.
Why won't this compile?
Upvotes: 0
Views: 2850
Reputation: 65
DO the following things and then try:
Upvotes: 3
Reputation: 5709
<stdlib.h>
... can be a noop if they are included before.If you want to make sure your file is compiled with C++, you can add this code to the begining of MasterTable.mm:
#ifdef __cplusplus
#error "compiled as C++"
#else
#error "compiled as C"
#endif
Upvotes: 1