A significant portion of my project is C-based, and I would like to use CocoaLumberjack for logging there. However, updating my prefix header to include CocoaLumberjack in plain C files causes endless headaches about Objective C types not existing.
I switch the types of the files to Objective-C++ , but get these errors upon attempting to call "DDLogVerbose":
/.../MDSystem.c:54:2: Cannot initialize a parameter of type 'DDLogLevel' with an lvalue of type 'const int'
On this line, to test, I had written this code:
DDLogVerbose(@"Hello, world!");
Does anyone know what might be causing these issues? Is there some special macros for logging directly from plain C code?
Can you share a sample project we can debug on?
I have uploaded an example project here. It is a console application targeting Yosemite, with an Objective C main function, and a C function in an Objective-C++ file that should print debug output as well.
However, this is the error log from Xcode:
I'm hoping this helps pinpoint the cause of this issue.
Have you tried the CLI Demo project?
I've resolved this issue. Instead of declaring ddLogLevel global in the prefix header as a const int, it should be declared of type const DDLogLevel as follows:
static const DDLogLevel ddLogLevel = LOG_LEVEL_VERBOSE;
This avoids the implicit typecast issues in the macros, and does not necessitate modifications of the framework itself.
:+1:
Most helpful comment
I've resolved this issue. Instead of declaring
ddLogLevelglobal in the prefix header as aconst int, it should be declared of typeconst DDLogLevelas follows:static const DDLogLevel ddLogLevel = LOG_LEVEL_VERBOSE;This avoids the implicit typecast issues in the macros, and does not necessitate modifications of the framework itself.