mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #579] custom strings doesn't work in VS2017 #483
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#483
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sidey79 on GitHub (Mar 30, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/579
Basic Infos
Using custom strings doesn't work with VS2017 . I think, with Arduino IDE this is the same.
Hardware
WiFimanager Branch/Release: Development
Esp8266:
Hardware: esp-01
Core Version: 2.4.1
Description
Problem description
Adding a #define WIFI_MANAGER_OVERRIDE_STRINGS in another header file or even in the main .ino file doesn't get recogniced when the WIFIManager lib itself is compiled.
The code example shows, that no error is trown, because the definition is not present inside the strings_en.h which is loaded by wifimanger.h
Settings in IDE
Module: Generic 8266
Code
@tablatronix commented on GitHub (Mar 30, 2018):
What happens if you define in build flags, or define and include in another header file?
Im pretty sure you cant define like that
@sidey79 commented on GitHub (Mar 31, 2018):
Arduino IDE or VS2017 doesn't allow defining build flags easy.
But i am sure, with build flags anything would be fine.
If i put the defines in another header file it is the same.
I think the way to fix this is moving the const vars out of strings_h into wifimanager.h and create #defines for the values.
Defaults can be in anything like en_default_str.h and custom strings should go into user_strings.h or something similar.
It should be possible, to control which one is used via #WIFI_MANAGER_OVERRIDE_STRINGS it the check is done in wifimanager.h.
But i haven't tested that idea.
@sidey79 commented on GitHub (Apr 1, 2018):
I did some tests yesterday but defines are never populated to libs. There ist no dependency from the lib back to the main Programm.
It is may possible, when moving all the code into the header file. But this isn't good coding style.
Another approach ist to specify a interface object. Instantiate this interface object and pass it as reference in the constructor.
If someone want to change the text, he could define a new class based on the template / Interface.
Going ahead, putting a file on spiffs may also a solution. Putting the file first time on the esp may a little bit tricky.
@tablatronix commented on GitHub (Jul 24, 2018):
I have read and tested this over and over and still cannot figure it out. I cannot get a compiler macros in the ino to be recognized in a library.
I have seen it done, the blynk library uses a sketch define for debug mode, and it works.
@sidey79 commented on GitHub (Jul 24, 2018):
This is, because the header file is compiled independent from the sketch and later linked.
@tablatronix commented on GitHub (Jul 24, 2018):
Ok I have it working now.
BUT you cannot define strings in the scope of the library...
ugh
I cannot declare the consts in sketch NOR in an include file.
@tablatronix commented on GitHub (Jul 24, 2018):
ugh I dont get C++ linker at all
I thought all consts in
strings_enwould be global and externalMaybe I need to declare and init seperatly, use flag extern ...
I give up
@sidey79 commented on GitHub (Jul 24, 2018):
I dont think, that it is possible with includes, because the includes are compiled seperatly and the defines are not populated as compiler flags.
Think about, that a library is normaly something that is compiled independent from a programm.
serval programs should be able use the same library.
So don't think about defines. Use templates or pass the variables from the main program.
@tablatronix commented on GitHub (Jul 24, 2018):
I am not concerned with defines atm. I am trying to figure oht the scope of the consts in strings.h .
I thought all includes were precompiled at once as one scope not separately. And all consts would be global and external.
@tablatronix commented on GitHub (Jul 25, 2018):
Ahh I think const are internally linked by default