Error: 'class name' redeclared as different kind of symbol?
I was facing the same error as asked in this question
I overcome with this error by solution of declaring class ahead of time in my .h file with the class parameter
I am having FFTBufferManager.h and FFTBufferManager.cpp
f开发者_开发问答ile and using it in HomeView.h and HomeView.mm
file
class FFTBufferManager,CAStreamBasicDescription,DCRejectionFilter;
But now I am having error as
#include "FFTBufferManager.h"
#include "aurio_helper.h"
#include "CAStreamBasicDescription.h"
class CAStreamBasicDescription,FFTBufferManager; //here it shows this error
EXpected Unqualified-id befor ',' token
@interface HomeView
{
FFTBufferManager* fftBufferManager;
//it shows erros
EXpected Unqualified-id befor ',' token
ISO c++ forbids declaration of FFTBufferManager with no type
}
@property FFTBufferManager* fftBufferManager;
//shows error
'FFTBufferManager' is not a type
I'm gathering you're using both C++ and Objective-C.
I'd suggest renaming all your .cpp
and .m
files in which Objective-C and C++ code are meeting to use the extension .mm
- this tells the compiler to use "Objective-C++" rules, and will stop a lot of compiler troubles.
Also, it seems CAStreamBasicDescritpion
is a C++ class - you'll have to forward-declare it with class CAStreamBasicDescritpion;
, not @class CAStreamBasicDescritpion;
(note, no "at" sign) - the second form is only for forward-declaring Objective-C classes. This I suspect is the root cause of the particular error you have observed.
EDIT in response to comment: I'm not sure about your first new issue - that should work fine so long as both FFTBufferManager
and CAStreamBasicDescription
are C++ classes. As to your second one, depending on where exactly that line of code is (CAStreamBasicDescription thruFormat;
) you may need to include the header rather than just the forward-declare: you're declaring an instance of CAStreamBasicDescription
here, and the compiler needs to know its structure to do so.
You can't declare more than one class at a time.
Change your declarations to
class CAStreamBasicDescription;
class FFTBufferManager;
The compiler is looking for an unqualified-id
because it believes that you're declaring a variable of type CAStreamBasicDescription
, so it expects a variable name where you gave it a comma.
Looks like you are trying to create a class that already exists in one of the Cocoa frameworks.
精彩评论