AlexK17 Posted November 12, 2018 Report Share Posted November 12, 2018 Hi. GSourceHandle enterHandle = ginputGetToggle(GINPUT_TOGGLE_ENTER); Why can this string cause a compiler error? Error[Pe059]: function call is not allowed in a constant expression but if use #define enterHandle ginputGetToggle(GINPUT_TOGGLE_ENTER) It does not cause an error and works fine. Compiler IAR 7.5 Best regards, Alexandr. Link to comment Share on other sites More sharing options...
inmarket Posted November 12, 2018 Report Share Posted November 12, 2018 If the line specified is right at the top of the function my guess is that it will work. If it is not at the top then you are running into a common C, C++ language misconception. C does not allow variable definitions except at the top of a block. Once a non-variable definition statement has occurred variable definitions are not allowed in the block. Whilst the C language does not allow this, C++ does. As many C compilers have associated C++ compilers many C compilers relax the rules and allow such definitions eg gcc. My guess is that the IAR C compiler follows the language standard and doesn't allow this. In general in C it is a good idea to seperate variable definitions from code to set the variables. Link to comment Share on other sites More sharing options...
AlexK17 Posted November 14, 2018 Author Report Share Posted November 14, 2018 Hi. Thanks for assist. Best regards. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now