Skip to content
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

ARDUINO_VARIANT cannot be cast to (char*) when compiling in Eclipse/windows #2193

Closed
Bascy opened this issue Dec 15, 2018 · 15 comments
Closed
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@Bascy
Copy link
Contributor

Bascy commented Dec 15, 2018

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: commit ec3a97b (dec 15)
IDE name: Eclipse / Sloeber 4.3 plugin
Computer OS: Windows 10

Description:

On compilation of the ESPmDNS component the following code results in an error
error: 'esp32' was not declared in this scope
because the macro ARDUINO_VARIANT is replaced by esp32 and not by the string "esp32"

void MDNSResponder::enableArduino(uint16_t port, bool auth){
    mdns_txt_item_t arduTxtData[4] = {
        {(char*)"board"         ,(char*)ARDUINO_VARIANT},
        {(char*)"tcp_check"     ,(char*)"no"},
        {(char*)"ssh_upload"    ,(char*)"no"},
        {(char*)"auth_upload"   ,(char*)"no"}
    };

@Bascy
Copy link
Contributor Author

Bascy commented Dec 15, 2018

Guess this should be solved as described here:
https://www.guyrutenberg.com/2008/12/20/expanding-macros-into-string-constants-in-c/

@atanisoft
Copy link
Collaborator

This is more likely an issue with how you are compiling in Eclipse. In Arduino IDE (https://github.com/espressif/arduino-esp32/blob/master/platform.txt#L68) and PIO (https://github.com/espressif/arduino-esp32/blob/master/tools/platformio-build.py#L94) it is passed in as a quoted string.

So, how are you building in Eclipse?

@Bascy
Copy link
Contributor Author

Bascy commented Dec 15, 2018

Using Eclipse plugin from Sloeber, The following definition of ARDUINO_VARIANT is used:

-DARDUINO_VARIANT="esp32"

I'm guessing that Eclipse / windows is loosing the double quotes somewhere

@lbernstone
Copy link
Contributor

Can you add something about eclipse env quoting to the issue title so the next person finds this?

@Bascy Bascy changed the title ARDUINO_VARIANT cannot be cast to (char*) ARDUINO_VARIANT cannot be cast to (char*) when compiling in Eclipse/windows Dec 15, 2018
Bascy added a commit to I-Connect/arduino-esp32 that referenced this issue Dec 15, 2018
@atanisoft
Copy link
Collaborator

atanisoft commented Dec 15, 2018

@Bascy the difference is how the quotes are declared, can you try:

-DARDUINO_VARIANT="\"esp32\""

The same issue could also likely be seen with ARUDINO_BOARD as well if you dig into it further.

@Bascy
Copy link
Contributor Author

Bascy commented Dec 15, 2018

Yes this also solves the problem for me, but as i understand it the problem only occurs when compiling on Eclipse and/or Windows OS.
So I make a pull request with a solution to this, implemented only when using Eclipse

@atanisoft
Copy link
Collaborator

As mentioned on your other issue, I think these are issues you should be opening against Eclipse Sloeber and not arduino-esp32. The PR you opened may be a solution for this issue BUT there will likely be many more issues as you continue adventuring down the path of an IDE that isn't very well documented or used extensively.

@Bascy
Copy link
Contributor Author

Bascy commented Dec 15, 2018

I've been using this IDE for over a year now with different boards and havent had this problem before. I'm guessing this is the only place in the arduino-esp32 core or any other cores that i've been using that casts the result of a macro expansion of a commandline -D define into a (char*)

@atanisoft
Copy link
Collaborator

I used to use Eclipse Sloeber but got fed up with lack of support and moved over to Platform IO which is considerably faster and more stable for me.

But for this issue, I suspect this is just the first of a few areas that use these defines.

Did you create the makefile you are building with or was it generated by Sloeber? If it was done by Sloeber you should probably open an issue against it so they can ensure this gets passed in correctly for any other constants.

@Bascy
Copy link
Contributor Author

Bascy commented Dec 16, 2018

It is generated by Sloeber but I think that it is Windows that removes the quotes as it passes the parameter value to the executable.
Did you use Sloeber on Windows or on a different OS?

@atanisoft
Copy link
Collaborator

Since it was generated by Sloeber, I'd guess they are not generating it correctly. The quotes are considered optional on all platforms and can be stripped by the shell (even on linux). I'd still suggest open a bug for Sloeber so they can work on a proper fix since they are breaking it with their template.

As for when I used Sloeber, I used it on windows for the ESP8266 and Arduino. I use Eclipse itself for other languages and targets but no longer for Arduino/ESP8266 and never for ESP32 (it wasn't supported at the time).

me-no-dev pushed a commit that referenced this issue Dec 16, 2018
* Replaced ARDUINO_VARIANT with const char

* Fixed missing return value

* Added quotes around defined value in macro (Issue #2193)
me-no-dev pushed a commit that referenced this issue Apr 15, 2019
* Replaced ARDUINO_VARIANT with const char

* Fixed missing return value

* Added quotes around defined value in macro (Issue #2193)

* Change logging from Error to Verbose when not found and default available

* Move Enter and Exit logging to Verbose Level

* Refactored LOG_X() into log_x()
@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
@ankit-thealchemist
Copy link

Getting the same problem using eclipse, arduino core as a plugin

@atanisoft
Copy link
Collaborator

@ankit-thealchemist file an issue against the arduino plugin for eclipse...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

4 participants