Setup and loop multiple definitions during compile

I recently received and set up a Photon.

The sample applications compile and flash properly from

However, when I compile the code in the local IDE, Particle Dev, even the ‘Blink an LED’ sample application generates compile errors.

The errors I am seeing are:
"multiple definition of ‘setup’ ", and
"multiple definition of ‘loop’ ".

The compiler flags that ‘setup’ is on lines 6 and 39.
The compiler flags that ‘loop’ is on lines 10 and 55.

This is confusing, since the sample application, ‘Blink an LED’, only has one definition for each. The sample application is unmodified.

Is the cloud compiler adding some definitions before the compile step?

This is such a fundamental issue that I am sure the fix is straightforward. However, I have not seen a direct solution in the forum.

Thank you for the assistance in solving this issue.

1 Like

Can we see a screenshot of your code in Particle Build?

With the error message too, please.

Sure. Here is the screen capture.

The line numbers correspond to the ones in the sample application. Nothing in the sample application has been modified. ‘setup’ is on line 39 in the ‘Blink an LED’ sample application, and ‘loop’ is on line 55 in the ‘Blink an LED’ sample application. Lines 6 and 10 are comments in the ‘Blink an LED’ sample application.


Hi @jrotella,

Do you have multiple application files in the same folder? Dev might be picking up other source files with setup/loop in the same folder?


Have you got the most recent version of Particle Dev?
Have you definetly saved the file before build, since only the saved versions get used for compile. If you alter your code, you see one version, but the errors may refer to the saved version.

Additionaly as I recall, there was a time where the preprocessor seemd to treat commented lines as active code.
I thought this issue was long gone, but who knows.

Some work arounds were to add a blank first line, or use #pragma SPARK_NO_PREPROCESSOR
You could also try a block comment /* */ in addition to the line comment //

And of course @Dave’s hint.

1 Like

Thanks for the interactivity.

With your assistance and some intuition, the issue has been solved. Here is what happened.

  1. I am running Particle Dev version 0.0.24.
  2. Initially, I actually did have more than one .ino file in the build directory, so I moved the .ino file of interest to its own folder.
  3. Though I put the .ino file of interest in its own build directory, the compiling issue did not go away (This could be based on some residual state in the cloud from the previous compile. I’m not 100% sure.).
  4. To rectify, I uninstalled Particle Dev and then reinstalled it.
  5. After 4., I made a directory with only the .ino file of interest contained in it.
  6. Based on the fresh install of 4., the compile and flashing completed successfully.

Thank you ScruffR and David.