I’m getting started in this Particle world and I like the small WiFi package, but I hate the Arduino legacy…
Can someone show me how to use the online compiler with C++?
- Do I have to have a *.ino file for my main?
- Where do I find libraries compatible with the toolchain?
- For example: How do I use a std::list?
- Is there such a thing as a Makefile for cloud compiling?
- If not, how do I tell which file is used as the “main”?
- Can I compile my C++ libraries into binary and then include them in my *.ino?
@fossum_13, welcome! Compiling using the IDE, CLI or DEV is a great way to produce your code. For absolute control over your environment, you may want to consider a local toolchain.
Do I have to have a *.ino file for my main?<
In the cloud, the .ino file is treated much like Arduino does with pre-compilation to handle things like function prototypes. Your IDE "app" has a .ino extension by default.
Where do I find libraries compatible with the toolchain?
For example: How do I use a std::list?
I suggest you read the documentation to give you some guidance. Many libraries are built-in to the firmware while many others are available in the IDE. You can add your own as well.
Is there such a thing as a Makefile for cloud compiling?
The IDE, CLI and DEV do not support a user make file. For that, you need to compile locally with a toolchain.
If not, how do I tell which file is used as the "main"?
Much like Arduino, the "main" program is defined as the one containing void setup() {};
and void loop() {};
functions.
Can I compile my C++ libraries into binary and then include them in my *.ino?
No, the IDE, CLI and DEV don't support this. Again, you may want to consider a local toolchain.

Thanks for the reply @peekay123 I still have some questions though.
I suggest you read the documentation to give you some guidance. Many libraries are built-in to the firmware while many others are available in the IDE. You can add your own as well.
Let's say I'm trying to add a Serial connection to my C++ header/source. So, I go over to https://docs.particle.io/reference/firmware/photon/#serial and attempt to locate the #include
file. Problem is, Particle does not list such a thing, because in Arduino land, no includes are necessary.
Much like Arduino, the "main" program is defined as the one containing void setup() {}; and void loop() {}; functions.
Problem is, (although artificially contrived) you can have two files with setup()
and loop()
. How do I tell which is running? I know it should be easy to tell, but it's just an example of the issue.
Can I compile my C++ libraries into binary and then include them in my *.ino?
I did just learn that I can use an int main()
in a file to act as a starting point, but I might run into the same dual main()
issue stated above.
I want to do the local toolchain route, but I had a bunch of trouble with it and wanted to get started developing. Maybe I'll try it again in a few weeks.
@fossum_13, you can find all the built-in libraries and functions documented here:
https://docs.particle.io/reference/firmware/photon/
The only include you need for those is #include application.h
which is included automatically for .ino files.
The only comment regarding two copies of setup() and loop() would be that you only have one!
The standard C main() function is built into the system firmware and I suggest you not try and create another.
It is important to note that Particle provides a “platform” which elevates the code above the type bare metal C code. You will be well served to read the reference docs first.
As for the local toolchain, share your challenges with the Community and we’ll see if we can help! 