aharren / LibComponentLogging-Core

A small logging library for Objective-C applications (Mac OS X and iPhone OS/iOS) which provides conditional logging based on log levels and log components. Additionally, different logging strategies can be used, e.g. writing log messages to a file or sending them to the system log, while using the same logging interface.
http://0xc0.de/LibComponentLogging
110 stars 11 forks source link

Xcode 8 build errors #31

Closed SpacyRicochet closed 6 months ago

SpacyRicochet commented 7 years ago

The files (not installed with the Pod) currently give build errors in Xcode 8.

screen shot 2016-11-09 at 11 41 05

It looks like the main culprit is this bit of code. The complier seems to get confused about the #define cutting off the enum declaration.

// Log components, prefixed with 'lcl_c'.
enum _lcl_enum_component_t {
#   define  _lcl_component(_identifier, _header, _name)                        \
    lcl_c##_identifier,                                                        \
  __lcl_log_symbol_lcl_c##_identifier = lcl_c##_identifier,
#   include "lcl_config_components.h"
#   undef   _lcl_component

   _lcl_component_t_count,
   _lcl_component_t_first = 0,
   _lcl_component_t_last  = _lcl_component_t_count-1
};

Any idea on how to solve this?

SpacyRicochet commented 7 years ago

Strangely enough, if I change that line of code to the below code, it builds fine. Obviously, this is not ideal, since I'm not using the configuration header and just typing its again in the enumeration.

// Log components, prefixed with 'lcl_c'.
#   define  _lcl_component(_identifier, _header, _name)                \
            lcl_c##_identifier,                                        \
            __lcl_log_symbol_lcl_c##_identifier = lcl_c##_identifier,

enum _lcl_enum_component_t {
   _lcl_component(MyTracker,  "My.Tracker",  "My/Tracker")

   _lcl_component_t_count,
   _lcl_component_t_first = 0,
   _lcl_component_t_last  = _lcl_component_t_count-1
};
#   undef   _lcl_component
aharren commented 7 years ago

Is this a module build?

SpacyRicochet commented 7 years ago

I'm slightly unsure on what you mean by 'module build', but to clarify; We've integrated the project to be used by one of our own internal pods, so it's a part of that Pod's code.

Integrating it as a Pod itself also didn't work, since it would't compile past needing a lcl_config_components.h file. After hacking that, it would still not compile due to the compiler error I mentioned.

aharren commented 7 years ago

If the Pod is built as a (clang-style) module, then the macro/include mechanism doesn't work anymore, because includes are only processed once :(

aharren commented 7 years ago

You might want to try the trick that was done in RestKit, they changed the component definition into 1 macro: https://github.com/RestKit/RestKit/blob/development/Code/Support/lcl_config_components_RK.h#L52-L63