raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.23k stars 279 forks source link

``TextToFloat`` was not declared in this scope when compiling a raygui program #407

Open Justaus3r opened 1 month ago

Justaus3r commented 1 month ago

Whenever i compile the example given in raygui Readme or any other source file that uses raygui. It errors out on following:

In file included from tst.cpp:4:
C:\raylib\raylib\src/raygui.h: In function 'int GuiGroupBox(Rectangle, const char*)':
C:\raylib\raylib\src/raygui.h:1624:180: warning: enumerated mismatch in conditional expression: 'GuiControlProperty' vs 'GuiDefaultProperty' [-Wenum-compare]
 1624 |     GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
      |
              ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\raylib\raylib\src/raygui.h:1625:199: warning: enumerated mismatch in conditional expression: 'GuiControlProperty' vs 'GuiDefaultProperty' [-Wenum-compare]
 1625 |     GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, RAYGUI_GROUPBOX_LINE_THICK }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
      |
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\raylib\raylib\src/raygui.h:1626:199: warning: enumerated mismatch in conditional expression: 'GuiControlProperty' vs 'GuiDefaultProperty' [-Wenum-compare]
 1626 |     GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - 1, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
      |
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\raylib\raylib\src/raygui.h: In function 'int GuiLine(Rectangle, const char*)':
C:\raylib\raylib\src/raygui.h:1647:74: warning: enumerated mismatch in conditional expression: 'GuiControlProperty' vs 'GuiDefaultProperty' [-Wenum-compare]
 1647 |     Color color = GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR));
      |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\raylib\raylib\src/raygui.h: In function 'int GuiPanel(Rectangle, const char*)':
C:\raylib\raylib\src/raygui.h:1695:112: warning: enumerated mismatch in conditional expression: 'GuiControlProperty' vs 'GuiDefaultProperty' [-Wenum-compare]
 1695 |     GuiDrawRectangle(bounds, RAYGUI_PANEL_BORDER_WIDTH, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED: LINE_COLOR)),
      |                                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\raylib\raylib\src/raygui.h:1696:77: warning: enumerated mismatch in conditional expression: 'GuiControlProperty' vs 'GuiDefaultProperty' [-Wenum-compare]
 1696 |                      GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BASE_COLOR_DISABLED : BACKGROUND_COLOR)));
      |                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\raylib\raylib\src/raygui.h: In function 'int GuiValueBoxFloat(Rectangle, const char*, char*, float*, bool)':
C:\raylib\raylib\src/raygui.h:3009:43: error: 'TextToFloat' was not declared in this scope
 3009 |             if (valueHasChanged) *value = TextToFloat(textValue);
      |                                           ^~~~~~~~~~~

At first i thought, i was using incompatible versions with raylib or something. I changed those but it didn't help. I tried with cmake toolchain, installing the packages with vcpkg. But the same error persists. Raylib works perfectly fine for me. The problem only occurs when i try to include raygui. Here's the Screenshot: image

I am on WIndows 11 with w64devkit and gcc V 13.2.0

emrekz commented 1 month ago

The following function can be moved from raygui.h to raylib.h

// in raygui.h
static float TextToFloat(const char *text)

raylib.h has similar functions but doesn't include the TextToFloat(const char *text)

// in raylib.h
RLAPI const char *TextToPascal(const char *text);      // Get Pascal case notation version of provided string
RLAPI int TextToInteger(const char *text);            // Get integer value from text (negative values not supported)
.
.
sprinkuls commented 1 month ago

i had this same issue, and it's caused by a mismatch in the version of raygui and raylib. basically, if you're using the 5.0.1 version of raylib (which is what you'd get from either the releases page or from a package manager), and then try to use the most recent raygui from this repo, you'll get errors since raygui ends up relying on raylib features that aren't yet in the newest released version (like texttofloat). to fix this you can either build raylib from source as described in the raylib wiki, and continue to use the newest possible raygui, or you can use the 5.0.1 version of raylib with something like the 4.0 release of raygui.

Justaus3r commented 1 month ago

i had this same issue, and it's caused by a mismatch in the version of raygui and raylib. basically, if you're using the 5.0.1 version of raylib (which is what you'd get from either the releases page or from a package manager), and then try to use the most recent raygui from this repo, you'll get errors since raygui ends up relying on raylib features that aren't yet in the newest released version (like texttofloat). to fix this you can either build raylib from source as described in the raylib wiki, and continue to use the newest possible raygui, or you can use the 5.0.1 version of raylib with something like the 4.0 release of raygui.

Thank you. I did try to build raylib from source and then use the latest version of raygui with it. But the personally built version also didn't work with raygui for me and it kept giving me the same error. In the end I just ditched raygui and ended up going with raylib only for my semester project

GuillemRamisa commented 4 weeks ago

I had the same issue, but I just put the function from raygui.h

static float TextToFloat(const char *text)
{
...
}

before this function, which is the one screaming

int GuiValueBoxFloat()

And now I can compile without any errors. I'm using raylib/5.0.0 and the latest raygui/4.1-dev

komatr-supra commented 3 weeks ago

so last raylib and last raygui isnt working....

alexlnkp commented 3 weeks ago

I had the same issue, but I just put the function from raygui.h

static float TextToFloat(const char *text)
{
...
}

before this function, which is the one screaming

int GuiValueBoxFloat()

And now I can compile without any errors. I'm using raylib/5.0.0 and the latest raygui/4.1-dev

Can confirm, works like a charm! Raylib from pkgmanager, versions of raygui and raylib are the same as yours. Thank you :)

komatr-supra commented 3 weeks ago

its working with vcpkg.