views:

6726

answers:

8

I'm trying to port the speakhere example into another app and I'm having issues. I copied all the files, and all the frameworks, but for some reason I get a bunch of compile errors that I've never seen before and thus don't know what to do. The only difference is that i'm not suing IB and so i had to change it slightly.

What does error: expected '=', ',', ';', 'asm' or '__attribute__' before 'foo' mean?... I get this error multiple times for different files

In my situation the first error is pointing at 'MeterTable'.. a class that includes <stdlib.h>,<stdio.h> and <math.h>. But those files seem to be importing fine (if i remove them i get more errors)

Any suggestions on how to debug this?

TIA!

EDIT: I still can't seem to figure it out. I'm literally just copying files from the example into another project. Can someone check it out please ? SpeakHerePort.zip and the original is here SpeakHere.zip

A: 

It means that you have a syntax error. If you paste the code in question, it's easier to debug.

Eric
Well the strange part is the fact that Even when I takeout any custom code, I still get errors, and its errors from files that I simply copied from the example, not even copoy/paste but the entire files. So Its almost like its something i'm missing as a project settup. But other then importing all the same frameworks I dont know what else it can be
dizy
If it was an error from some specific file i'd post the source, but its the same error spanning multiple files which all work fine in the example
dizy
+1  A: 

It sounds like an unfinished declaration, probably in a header file. Search for 'foo' (or whatever the symbol actually is) across all project files, using ⇧⌘F (Edit ▸ Find ▸ Find In Project...) in Xcode, and/or examine the headers you're including where MeterTable is declared. Sometimes the compiler gets confused about the actual location of the error, since header files are frequently #imported into other files, so the problem can be manifest in multiple locations.

Quinn Taylor
A: 

Whenever I get that error, it is simply a missing semi-colon. double check!!

Dutchie432
+14  A: 

Your problem is that you are compiling SpeakHerePortAppDelegate.m, which is an Objective C file, but it is indirectly including MeterTable.h which is a C++ header file.

Rename it to SpeakHerePortAppDelegate.mm (double m) so that it is compiled as Objective C++ and your problem is resolved.

Name all your files .mm and then all your code will be compiled as Objective C++

Peter N Lewis
A: 

This might not have applied to this exact situation, but I had this exact error too, which was caused by a bad forward declaration. In Objective-C, make sure your forward-declares begin with the @ sign - e.g.

@class MyClass;

Those of us still on autopilot from C++ will forget the @, see that XCode has highlighted class as a reserved keyword, and think all is well with the world. It is not.

Matt
A: 

I had a similar scenario to some of the posts above. I'd written a C++ class based off of the examples in the Audio Queue Services documentation, and had this compilation issue in a test project. This post helped a tremendous amount.

Today, I'm incorporating the C++ class in my project, and got the build error again. In my scenario, I had to also set the type (using the "Get Info" window) to sourcecode.cpp.objcpp for the objective-c class that was calling my C++ class.

oddmeter
A: 

oddmeter's answer worked for me, and I think it's the most correct answer in this case. Set the file type to sourcecode.cpp.objcpp.

Randy