-
-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues if MySensor.h gets included in sub-library #485
Comments
Hello @DerTomm. It is probably because of "scope of visibility" (called translation unit) of your defines. If I've understood correctly, in order to provide your own configurations of MySensor library, you need to put some defines in your local *.cpp file and then include MySensors.h, like this for example:
Your definitions will be visible only when compiling the current cpp file. If you include only MySensors.h in other cpp file as well, then the MySensors.h will complain that some defines are unknown - as there is a different translation unit. To overcome this you need to put the same defines again in the second file; or even better you can create your own configuration MyOwnConfig.h, put the defines there and include it always like this:
|
Thanks for these information. I finally managed to solve the issue with a forward declaration. Now the header files are used in the correct order so that MySensor.h sees its own definements. |
Hello! Just wanted to say hello to you and let you know that I found something interesting for you, look at it here http://spuphultunge.mblvid.com/e4bxs Rushing, johan |
Hi MySensors Team,
thanks for this great library.
After some playing around I started to develop software for my sensor nodes with the MySensors lib. Today I realized a problem which occurs when I am including "MySensor.h" within a class in a private library in one of my projects (because there I process a given MyMessage object as input parameter of one method). So MySensors.h is used twice - once in the main sensor node cpp and once in this library class. The result is a compiler error
Obviously the second include gets processed first - before the "MY_"-defines of the main class are parsed.
Is there any chance to include MySensor.h in other source classes without this behaviour?
The text was updated successfully, but these errors were encountered: