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

Fix invalid string cast #52408

Merged
merged 1 commit into from
Sep 8, 2021
Merged

Conversation

GiantBlargg
Copy link
Contributor

@GiantBlargg GiantBlargg commented Sep 5, 2021

In PR #51908 these lines were added:

ERR_FAIL_COND_V_MSG(error != 0, false, TTR("FreeType: Error initializing library:") + " '" + String(FT_Error_String(error)) + "'.");
ERR_FAIL_V_MSG(false, TTR("FreeType: Error loading font:") + " '" + String(FT_Error_String(error)) + "'.");

While this compiles when tools=yes, when tools=no it produces a compile error.

./core/string/ustring.h:526:22: error: invalid cast to function type 'String()'
  526 | #define TTR(m_value) (String())
./core/error/error_macros.h:94:26: note: in definition of macro 'DEBUG_STR'
   94 | #define DEBUG_STR(m_msg) m_msg
      |                          ^~~~~
modules/text_server_adv/text_server_adv.cpp:1234:25: note: in expansion of macro 'ERR_FAIL_COND_V_MSG'
 1234 |                         ERR_FAIL_COND_V_MSG(error != 0, false, TTR("FreeType: Error initializing library:") + " '" + String(FT_Error_String(error)) + "'.");
      |                         ^~~~~~~~~~~~~~~~~~~
modules/text_server_adv/text_server_adv.cpp:1234:64: note: in expansion of macro 'TTR'
 1234 |                         ERR_FAIL_COND_V_MSG(error != 0, false, TTR("FreeType: Error initializing library:") + " '" + String(FT_Error_String(error)) + "'.");
      |                                                                ^~~
./core/string/ustring.h:526:22: error: invalid cast to function type 'String()'
  526 | #define TTR(m_value) (String())
./core/error/error_macros.h:94:26: note: in definition of macro 'DEBUG_STR'
   94 | #define DEBUG_STR(m_msg) m_msg
      |                          ^~~~~
modules/text_server_adv/text_server_adv.cpp:1252:25: note: in expansion of macro 'ERR_FAIL_V_MSG'
 1252 |                         ERR_FAIL_V_MSG(false, TTR("FreeType: Error loading font:") + " '" + String(FT_Error_String(error)) + "'.");
      |                         ^~~~~~~~~~~~~~
modules/text_server_adv/text_server_adv.cpp:1252:47: note: in expansion of macro 'TTR'
 1252 |                         ERR_FAIL_V_MSG(false, TTR("FreeType: Error loading font:") + " '" + String(FT_Error_String(error)) + "'.");
      |                                               ^~~

A similar problem is also present in text_server_fb, but is disabled by default.

This PR alters the tools=no stubs of TTR and other Tool Translate functions to allow compiling again.

Copy link
Collaborator

@Faless Faless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I was a bit surprised this got interpreted as a cast, so, great work 👍 🥇 !

@Faless Faless merged commit e6106ed into godotengine:master Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants