Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: terry1 on July 14, 2019, 09:23:34 am
-
OK, I was running version 16.01, and I liked it, everything worked out great. I have recently downloaded the newer version 17.12, now I am having major problems. For every program I create I use the following inline function:
inline void keep_window_open(){char ch; scanf("%s", ch);}
then right before the return 0; statement I would call the function this way:
keep_window_open();
This never failed, all my program compiled. However with this new release, I get the error : undefined reference to keep_window_open.
Even in the simplest of programs such as:
#include <stdio.h>
#include <stdlib.h>
inline void keep_window_open(){char ch; scanf("%s", ch);}
int main()
{
printf("Hello world!\n");
keep_window_open();
return 0;
}
This will not compile, nothing will it use to in the older version, but now it won't
So what is up? I have my settings like they always were before, to use GNC GCC, I am using the console application template, just I like I always have before. So I do not understand why in this new version this won't work. Very frustrating.
-
You don't need that trick to keep the window open, just check Project->Options->Build targets->Pause when execution ends.
If you want to use your method the line scanf("%s", ch) with ch defined as a char is incorrect, you should use %c.
For the compilation error please post a full rebuild patch, see:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
-
This won't fix the undefined reference though. Apparently inline is quite tricky with C code, depending on the used standard the behavior is different, the newer CodeBlocks might ship a newer compiler that uses a different standard by default. The most easy fix would be to just remove the inline (im a C++ guy and don't know these little differences well).