Repeating character

I recently added OpenFeint code for my classes and changed them to .mm

Suddenly I get errors that duplicate characters in object files when created.

ld: duplicate the _audioPlayer character in blah blah / Objects-normal / i386 / Stage2.o and / Users / blah blah.build/Debug-iphonesimulator/blah.build/Objects-normal/i386/Stage1.o

Why does this suddenly cause this error? What is a mistake?

I have variables with the same name in different classes, should this be the problem?

thank

+3
source share
4 answers

You are probably declaring two variables with the same name in the global scope (not inside the interfaces), and the linker complains about it.

+3
source

This error can also occur if you import a .m file instead of .h.

#import "SomeClass.m"
+3

Short answer: you can suppress this error with the gcc command line argument: -Wl, - allow multi-disk definition

+1
source

If you implement your method, as shown below in the .mm file, there will be duplicate symbol error.

#import <Foundation/Foundation.h>

class CppTestOne 
{
public:
    void Test();
//    {
//        NSLog(@"Hello C Plus Plus");
//    }
};

void CppTestOne::Test()
{
    NSLog(@"Hello C Plus Plus");
}

then you can implement your method

#import <Foundation/Foundation.h>

class CppTestOne 
{
public:
    void Test()
    {
        NSLog(@"Hello C Plus Plus");
    }
};

//void CppTestOne::Test()
//{
//    NSLog(@"Hello C Plus Plus");
//}

more information about this error is fuzzy

+1
source

Source: https://habr.com/ru/post/1787998/


All Articles