Starting my second project with Particle (this time with a Photon), and am determined to get past a problem that I kludged in the first one. For reference, I’m using the Atom-based Particle Dev IDE.
For some reason, I cannot seem to be able to make calls to the Particle Firmware API anywhere outside of the main / INO file. Current example is any Wire (I2C) call. I’ve seen this done in other third-party libraries (e.g. those from SparkFun), and am including stdio.h, stdint.h, and application.h in my C source file. However, I’m now getting the following compilation errors:
system_version.h (53:19): expected ":", ",", ";", "}", or "_attribute_" before "=" token
spring_wiring_constants.h (31:23): type_traits: no such file or directory
Clues here? I’m hoping that this is a simple, stupid mistake, as I would really like to be able to make things a whole lot more modular going forward, as opposed to using the “big ball o’ code” INO design methodology.
Thanks, but I’m already doing so. Leaving out application.h gives me complaints about Wire not being declared.
Only after I include those three headers mentioned (or really only application.h) do I get the more cryptic error messages about system_version | _wiring_constants.
Yep, read right through that without registering it, sorry about that. I've yet to connect any I2C modules to my Photon. We should call in the big guns on this one. @ScruffR or @Moors7 any idea what's going on here?
If you show your code it might be easier to see your problem.
As you said, it’s possible and others do it all the time, so it’s most likely your code.
BTW: I’m not that big a gun More like a water pistol - there are others way cleverer, but I’m round a lot, so people just can’t help having to read my stuff
@IvanY, like @ScruffR said, it’s difficult to help without seeing some code. I have several libraries making Wire calls so I’m not sure what’s up with your code. Also, how are you compiling (IDE, CLI, DEV or local toolchain)?
Umm if I remember correctly this was an issue with Build not Dev. This seems to be just an issue of mixing C and C++ code without wrapping: https://isocpp.org/wiki/faq/mixing-c-and-cpp
As it turns out, simply renaming the C file to CPP resolves the compilation problem. (I’ve gone ahead and added the extern C section to the header file, as per the link provided by @suda.)
I admit that it has been eons since I’ve dabbled in C++, and so many of these requirements are somewhat foreign to me.