0

I'm currently trying to compile my project just after adding some C code.

I'm using the Paul Kocher's blowfish algorithm implementation available on Bruce Schneier's website.

Since I included blowfish.c & blowfish.h in my workspace, my compiler is running crazy. Like if it did not recognize Objective-c code, pointing errors on NSObject class!

I tried to .mm the calling class but the problem stays.

Each answer found on SO talks about including C++ file, but it's not my pb...

Maybe a compiler directive that i'v missed ?

Martin
  • 11,881
  • 6
  • 64
  • 110
  • c files should work no problem, but you probably need to wrap the header with `extern "C" { ... }`. Does it have that? – Dave May 24 '13 at 17:28
  • can you post a sample project? – Grady Player May 24 '13 at 17:30
  • @Dave: no it didn't. Could you tell me more? – Martin May 24 '13 at 17:31
  • @Grady: Aargh! It works on an empty sample project! – Martin May 24 '13 at 17:36
  • @Martin if it works in an empty sample project I would make sure that you aren't #includ'ing a .cpp file – Grady Player May 24 '13 at 17:39
  • @Martin I am stuggling with blowfish algorithm IOS, can you give me some suggestions or link of tutorial, please check my question http://stackoverflow.com/questions/19031842/dycrypt-value-from-blowfish-objective-c. – QueueOverFlow Sep 30 '13 at 07:58
  • @QueueOverFlow: I didn't succeeded to get the right output after encoding with bluefish and not enough time to check deeper. I finally gave up because of the poor documentation and everyone's advices. Sorry for that. – Martin Sep 30 '13 at 10:04

2 Answers2

1

Most likely, what is happening is that the compilation of blowfish.c is using your previously established precompiled header (.pch) file, and that is including an Objective-C framework. Just disable the precompiled header and you should be OK. You might be able to conditionalize those frameworks, but personally, I find precompiled headers more trouble than they’re worth.

microtherion
  • 3,938
  • 1
  • 15
  • 18
1

Thanks to microtherion, I found the problem.

My .pch file was declared as :

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif 

#import "AppDelegate.h"
#import "UINavigationController+Rotation.h"
#import "Categories.h"

The 3 last #import'ed files are objective-C.
I've just changed the #endif place to:

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>   

    #import "AppDelegate.h"
    #import "UINavigationController+Rotation.h"
    #import "Categories.h"
#endif    
Martin
  • 11,881
  • 6
  • 64
  • 110