tags:

views:

52

answers:

2

"VoiceName" is an enum, declared like this:

enum VoiceName {
 PAD_RHYTHM,
 PAD_RHYTHM2,
 PAD_RHYTHM3,
 PEEPERS,
 ATMOSPHERE,
 IMPULSE,
 FAST_PULSE,
 HAIRYBALLS_PADS,
 KICK
};

The compiler doesn't seem to like me using it in a method signature like this:

-(void)pulseFiredWithSamplePosition:(float)position from: (VoiceName) voiceName;

It tells me expected ')' before 'VoiceName'. What's going on here?

+4  A: 

You can't use it "bare" like that without also specifying that it's an enum:

-(void)pulseFiredWithSamplePosition:(float)position from: (enum VoiceName) voiceName;

should work. If you want to avoid specifying it like that, you can typedef it:

typedef enum _VoiceName {
    PAD_RHYTHM,
    ....
} VoiceName;

then you'll be able to use just VoiceName as the argument type.

quixoto
+1  A: 

Obj-C is based on C, not C++. C requires the enum keyword, as quixoto showed. C++ lets you omit it.

Graham Perks