simple preprocessor issue...

Hi All,

I’m quite loosing my mind here getting around a very simple preprocessor inclusion statement.

I’m trying to get ofxLibArtnet running on Linux. I have found what causes it not to run which is just setting some defines for the preprocessor. So to get it running on OSX and Linux I wanted to set certain defines based on what platform is targeted. If I do this the manual way it works but I can’t get it to do a conditional statement based on platform.

I tought I would do (in config.h):

  #define HAVE_ARPA_INET_H 1  
#ifdef TARGET_OSX  
  #define HAVE_SOCKADDR_SA_LEN 1\  

It just doens’t work. (Yes I did do make clean)

Is there anything I’m missing here?

In testapp.cpp I’m doing:

#include "testApp.h"  
#include "ofxLibArtnet.h"  

in ofxLibArtnet.h I’m doing:

#include "artnet.h"  

However in artnet.c private.h is included which includes config.h.

This is probably some inclusion/compiler order issue but I can’t see the forest through the trees… :slight_smile:



have you made sure that


is defined? cause in private.h it says:

# include <config.h>  

aside of that, if I were you I’d make any modifications if possible in ofxLibArtnet.cpp/.h - the stuff in libs is the artnet library itself - if you change code in there, it can’t be easily updated any more (cause your chagnes would have to be manually recreated when the artnet library is bumped to the next version.

Yes, I have two statements:

in config.make:


but also in ofxLibArtnet.h:

#define HAVE_CONFIG_H 1  

Btw the repo is here for reference:

Update: I’ve found a way to debug the preprocessor a bit by adding a #pragma message “hello world”. I can confirm TARGET_LINUX is not defined. Question is why?

if I change ifdef TARGET_LINUX to if 1 it works.

I just tried to compile against 0071 tag on github and it does work in that version. So this is an issue in the develop branch of OF…

strange. the relevant portion of the system finding code (for linux) hasn’t been touched in a long time.
maybe something undefines TARGET_LINUX?

would be great if you could find a minimal example (as small as possible) which reproduces the bug (i.e. different behaviour of TARGET_LINUX in 0071 and develop), and file a bug in the issue tracker, including system info etc.

I just tried a clean testApp from the projectGenerator with this code:

void testApp::update(){  
#ifdef TARGET_OSX  
#ifdef TARGET_WIN32  

It prints [error] linux. So it works fine.

If libartnet unsets TARGET_LINUX it would do so in all releases of OF I expect. So the only thing I can think of is in the makefile. Perhaps the addon code is preprocessed before OF? So that must be something in the makefile?

that’s a possibility I guess, but I’ll have to defer to arturo or someone else for this, I don’t know, sorry.

I just tried the makefiles from the master branch to compile with the develop branch but to no avail. This is a weird one…

can you post the error log?

It’s been a while but I was just going through the code again. OfxLibArtnet is compiled completely, no static libs.
artnet.cpp includes private.h which in turn includes config.h. The config.h sets specific settings for every platform. I’d thought to change this config.h (which is generated by configure) to set the settings based on TARGET_LINUX, TARGET_OSX etc. This doesn’t work.

I cloned the addon. You can see in the config.h I’m outputting warnings to see what gcc is doing:
I don’t get those warnings. (tested on Linux 0072/0073)

Now I’m going through this again and knowing a bit more about the order in the Makefile. It could be that the addon is compiled first. As the the config.h is included by artnet.cpp it will be compiled before any openFrameworks includes are parsed. So the TARGET_LINUX isn’t set and so the config.h is parsed wrong…

I think I need to change the preprocessing to check for: