2

Summary:

Error I'm experiencing is as title states. I'm encountering a Reference to '' is ambiguous error. I've been unable to determine what the problem, whether if my import structure is set up incorrectly and the headers are somehow included multiple times or whatnot.

Due to request and requirements, I'm currently trying to build a single view iOS application using Objective-C and C while importing a custom pure C SDK. This is my first time using C in an iOS application, let alone including a whole SDK, so I'm not 100% sure if the process I'm doing this is correct, but have been able to resolve errors as I've been compiling.

SDK files are being included via a prefix.h which is imported into the single viewcontroller's header. I also read somewhere to use .pch instead of .h, but I'm not able to figure out how to do so given the requirements of this project...

Errors:

Reference to 'E_EXTERNAL_DEVICE_TYPE__CARD_ENTRY_DEVICE' is ambiguous.
  • "In file included from .../ViewController.m" -"In file included from .../ViewController.h"
  • "In file included from .../prefix.h"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_TYPE__CARD_ENTRY_DEVICE'"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_TYPE__CARD_ENTRY_DEVICE'"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_TYPE__CARD_ENTRY_DEVICE'"
Reference to 'E_EXTERNAL_DEVICE_CONNECT_TYPE__BLUETOOTH' is ambiguous.
  • "In file included from .../ViewController.m"
  • "In file included from .../ViewController.h"
  • "In file included from .../prefix.h"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_CONNECT_TYPE__BLUETOOTH'"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_CONNECT_TYPE__BLUETOOTH'"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_CONNECT_TYPE__BLUETOOTH'"

Reference to 'E_EXTERNAL_DEVICE_TYPE__PRINTER' is ambiguous.

  • "In file included from .../ViewController.m"
  • "In file included from .../ViewController.h"
  • "In file included from .../prefix.h"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_TYPE__PRINTER'"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_TYPE__PRINTER'"
  • "Candidate found by name lookup is'_E_EXTERNAL_DEVICE_TYPE__PRINTER'"
// Device.c
...
// this and other similiar lines of code that throws the error
if((deviceType == E_EXTERNAL_DEVICE_TYPE__CARD_ENTRY_DEVICE) && E_EXTERNAL_DEVICE_CONNECT_TYPE__BLUETOOTH) {
  CODE x = E_EXTERNAL_DEVICE_TYPE__PRINTER;
}

Solutions attempted

The strange part is, at one point I was able to build and run parts of the project by interatively uncommenting lines and debugging lines of code as I went along starting with SDKInitialize. But for some unknown reason, I'm now getting this error even though I've commented the SDKInitialize() in ViewController.m such that it's just an empty ViewController doing nothing.

I've also tried reverting back an older git version where the project could build fine, but it's still encountering the same error, which possibly leads me to believe this may be related to the XCode IDE or some kind of configuration settings...

  1. cleaned project
  2. deleted everything inside '~/Library/Developer/Xcode/DerivedData/ModuleCache/'
  3. clean once more
  4. build project

Already checked

Build Settings

I have tried setting setting always_search_user_paths = No;

Always Search User Paths = Yes;  
Header Search Paths[$(PROJECT_DIR)/.../.../.../SDK/Common] = recursive;  
Header Search Paths[$(PROJECT_DIR)/.../.../.../SDK/Core] = recursive;  
Header Search Paths[$(PROJECT_DIR)/.../.../.../GenericAppRoot] = non-recursive;  
... etc

FYI app.xcodeproj exists inside ___/GenericAppRoot/Devices/iOS

File Structure

Common.h

//located in $(PROJECT_DIR)/.../.../.../SDK/Common
//Common.h
#ifndef __DTISDK_COMMON_H__
#define __DTISDK_COMMON_H__

//--------
// SDK Includes
//--------

//...

//--------------
// External Device Types
//--------------
typedef enum _E_EXTERNAL_DEVICE_TYPE
{
  E_EXTERNAL_DEVICE_TYPE__PRINTER = 1,
  E_EXTERNAL_DEVICE_TYPE__CARD_ENTRY_DEVICE = 2,
  E_EXTERNAL_DEVICE_TYPE__PIN_ENTRY_DEVICE = 3,
} E_EXTERNAL_DEVICE_TYPE;

//...

typedef enum _E_EXTERNAL_DEVICE_CONNECTION_TYPE
{
  E_EXTERNAL_DEVICE_CONNECT_TYPE__AUDIO = 1,
  E_EXTERNAL_DEVICE_CONNECT_TYPE__BLUETOOTH = 2,
} E_EXTERNAL_DEVICE_CONNECTION_TYPE;

//...

#endif //__DTISDK_COMMON_H__

prefix.h

#ifndef prefix_h
#define prefix_h

#include "File.h"
#include "File.c"
#include "System.h"
#include "System.c"
#include "Common.h"
... etc

ViewController.h

#import <UIKit/UIKit.h>
#import "prefix.h"

@interface ViewController: UIViewController

@end

ViewController.m

#import "ViewController.h"
@interface ViewController()
@end

@implementation ViewController
- (void) viewDidLoad {
  [super viewDidLoad];

  // initialization callback from one of the SDK classes
  SDKInitialize();
}
@end

Any additional help or insights would be much appreciated

Community
  • 1
  • 1
setzuiro
  • 427
  • 5
  • 13

1 Answers1

1

You are including *.c files from prefix.h which is wrong. Always include only header files (*.h).

When you are including the implementation (*.c) files, the contents of the file is inserted as is, therefore you get the same definition in multiple places, leading to name collisions.

Sulthan
  • 128,090
  • 22
  • 218
  • 270
  • I thought that was the case as well, but when I removed all .c references in the prefix.h, XCode throws me "Undefined symbols for architecture x86_64: "_SDKInitialize", reference from: -[ViewController main] in ViewController.o Edit: The ironic part is that, at one point before, even with the .c included (to remove undefined symbol), the project would build and run fine. – setzuiro Jul 04 '16 at 19:31
  • @setzuiro Then your `*.c` files are probably missing from the build. Make sure they are present in the build target. Don't add them to headers. – Sulthan Jul 04 '16 at 19:32
  • I'm not entirely sure if your suggestion actually worked, but I'm currently moving ahead with it to see how far I can get. The files now show up in the `Compile Sources` under `Build Phases`. But now it looks like it's complaining `EGL`, `GLES`, `GLES2` files not found and I don't know how to add them to iOS... Will come back to this in a bit... – setzuiro Jul 04 '16 at 20:42