FabioBatSilva / ArduinoFake

Arduino mocking made easy
https://platformio.org/lib/show/1689/ArduinoFake
MIT License
105 stars 48 forks source link

I tried it with PlatformIO and get undefined reference to `WinMain@16' #16

Closed ats3788 closed 2 years ago

ats3788 commented 4 years ago

Where has the main.cpp File to be I put it in the src folder.

ats3788 commented 4 years ago

It does not work in my case with the Arduino syntax setup() & loop() you have to change it to main() function.

trullock commented 3 years ago

I have this exact issue, what is the solution @ats3788

Thanks

maxgerhardt commented 2 years ago

When compiling for platform = native you need to define the main() function to generate a proper executable. The entry point of a normal PC program is not setup(). See official example for a way to automatically create the correct entry point.

prof7bit commented 2 years ago

The examples here in this repository all have setup() and loop() and NO main(), so are these examples wrong?

maxgerhardt commented 2 years ago

Huh?

Both of the examples here have the main function. It's intended for testing (pio test, sources in test/), not compilation of the src/ program on the native platform. If you want that, you need a main().

https://github.com/FabioBatSilva/ArduinoFake/blob/910fc5f7dbbdc9d9094aadd29e108bcea063c540/examples/wiring-blink/test/test_main.cpp#L32-L42

https://github.com/FabioBatSilva/ArduinoFake/blob/910fc5f7dbbdc9d9094aadd29e108bcea063c540/examples/mock-injection/test/test_my_service.cpp#L40-L47

So that's alright.

prof7bit commented 2 years ago

https://github.com/FabioBatSilva/ArduinoFake/blob/master/examples/wiring-blink/src/main.cpp

maxgerhardt commented 2 years ago

You're pointing at a source in src/. This library is intended for testing, the sources in test/ matter. src/ is supposed to be your embedded firmare, hence "real arduino" with setup() and loop, test/ the tests for your native machine, hence, main().

FabioBatSilva commented 2 years ago

Thanks for the clarification @maxgerhardt

@prof7bit , @ats3788 let me know if it still not clear..