Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Rakenar

macrumors newbie
Original poster
Jun 4, 2009
2
0
Hello everyone,

I got over 9000 "error: stray '@' in program", exactly where I use new Objective-C files (for such daring declarations as "@interface") , but some old Objective-C files who have those sort of declarations (beware! "@interface"!) do not generate those errors.

I did "Get Info" on the .mm files to put their type to sourcecode.cpp.objcpp, but somehow that didn't helped me at all. I also deleted all spaces near the declarations to no avail.

Please try to be as explicit as possible, I'm quite new at programming on Mac, and have a lot of troubles working with XCode (developpement is being done on visual, and we use XCode merely to get that code on iPhone directly), so I'll need as much info as possible.

Thanks all in advance!

P.S. : Maybe I'm not looking closely enough at my code, so I'll post a sample:
Code:
#ifndef __SOMECLASS_H__
#define __SOMECLASS_H__

#define	STATE_FAIL		-1
#define	STATE_IDLE		0
#define	STATE_WORKING	1
#define	STATE_SUCCESS	2
#define	STATE_POKE		3

@interface SomeClass : NSObject {
	int					status;
	long long			bytesReceived;
	char				finalLink[255];
	NSString*			downloadSource;
	NSString*			downloadDestination;
	NSURLResponse*		downloadResponse;
	NSMutableData*		receivedData;
}
This is the start of the file, and it produces the error on "@interface IGPLinkGrabber : NSObject {".
 
You're probably not compiling this file as obj-C. Instead it's probably C or C++. In the build window, in the middle there are four little icons on the left side. One of them looks like some text. Click it and you can see the build transcript. It should say something like this for an objective-C line:

CompileC build/AppName.build/Debug-iphonesimulator/AppName.build/Objects-normal/i386/MSourceFile.o /Users/username/develop/AppName/trunk/Classes/MSourceFile.m normal i386 objective-c com.apple.compilers.gcc.4_0
 
Thank you, I had to go into the project settings and change the "Compile Sources As" to Objective-C++ (was previously at "According to File Type", but apparently that didn't do anything).

Everything is now fine, thank you very much! :D
 
Objective-C++ and C++

Hi,
I'm very new to mac and I am trying to compile some demo programs of JUCE. After a huge, many-day headache, I am able to compile the code within x-code. So now I'm trying to migrate that to NetBeans because I find that IDE much more useful. However, I'm having some troubles with objective c++ I think. At first I got problems with @ symbols in the mac code that is referenced by the files I'm trying to compile. It seems that has something to do with "objective c" or "objective c++" which are both something I have never heard of. Fortunately, I found that gcc supports this strange term with a command line argument of '-ObjC' which apparently only works for macs. Even when I do this though, there seems to be a problem of c++ no longer being recognized. For example, the following basic template is not recognized:
template <bool b> struct JuceStaticAssert;
error: syntax error before '<' token
Does anyone have any ideas for me?
Does anyone know what the '@' is doing in the objective c++ code?
Thanks,
Sean
 
hello ! there.

i am new to the objective c delelopement.

for me objective c is like:eek::confused:.

but i have to learn it any how as it is part of my duty.:(

so, i have a problem.

problem is i can't set @required and @optional in my protocol file.

i am using mingw32 from windowsxp & i am using gcc compiler.
compiler gives erros something like following
/*
shape.h:2: error: stray '@' in program
shape.h:3: error: syntax error before '-' token
shape.h:7: error: stray '@' in program
shape.h:8: error: syntax error before '-' token
main.m: In function `main':
main.m:11: warning: `rectangle' may not respond to `-displayArea'
main.m:11: warning: (Messages without a matching method signature
main.m:11: warning: will be assumed to return `id' and accept
main.m:11: warning: `...' as arguments.)
main.m:12: warning: `rectangle' may not respond to `-h'
main.m:16:2: warning: no newline at end of file
*/

my original protocol file is as below - shape.h
/*
@protocol shape
@optional
-(int) h;
-(int) w;
-(void) seth : (int) a;
-(void) setw : (int) b;
@required
-(void) displayArea;
-(void) setx : (int) a;
-(void) sety : (int) b;
-(int) x;
-(int) y;
@end
*/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.