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

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

Open
Justaus3r opened this issue May 28, 2024 · 7 comments

Comments

@Justaus3r
Copy link

Justaus3r commented May 28, 2024

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
Copy link

emrekz commented Jun 1, 2024

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
Copy link

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
Copy link
Author

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
Copy link

GuillemRamisa commented Jun 10, 2024

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
Copy link

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

@alexlnkp
Copy link

alexlnkp commented Jun 14, 2024

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
Copy link

its working with vcpkg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants