C assert run/debug aborts but no output. Shows output when exe ran in terminal
Answered
Clion 2020.3 simple test of assert in C99 program
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
int main() {
printf("Before assert\n");
assert(false);
printf("After assert\n");
return 0;
}
When I use run/debug the assert fails, does a dump file, and aborts as expected but no output is shown.
Expected output shows if I switch to terminal tab or external cmd.exe or cygwin bash.exe and run the exe manually.
Expected output:
$ ./AssertionTest.exe
Before assert
assertion "false" failed: file "/cygdrive/c/Users/isimmons/code/C/EffectiveC/ch6/AssertionTest/main.c", line 7, function: main
Aborted (core dumped)
Actual output when using run/debug:
C:\Users\isimmons\code\C\EffectiveC\ch6\AssertionTest\cmake-build-debug\AssertionTest.exe
Before assert
Process finished with exit code 0
So it is working, but just not showing the output.
Thanks,
Please sign in to leave a comment.
Hello!
What toolchain do you use in CLion?
I can't reproduce the issue on my side. Here are my results:
Cygwin
MinGW
MSVC
Thank you for the reply.
I did some more testing. On Windows 10 Pro 64 I get similar output to yours for MSVC and MingGW. The additional message at the bottom of MingGW is missing on mine ("This application has requested the Runtime to terminate...") but that's no big deal.
I still get no output for cygwin64. I did have an issue with detecting gdb at initial installation and had to downgrade the major version to make it match with gcc major version to make it detect correctly but I think that's a separate issue.
On Mac OS Big Sur I get the output correctly with both clang from xcode tools and the system gcc/gdb executables so that narrows it down to a windows/cygwin issue I guess.
On a related but not important issue, MSVC also shows the annoying popup alert. I know this is not a jetbrains issue but is there a way to turn that off in Clion?
MSCV
MingGW 64
Cygwin64
You can try disabling PTY as a workaround for Cygwin: go to Help | Find Action, type "Registry...", select it and in the opened list find and disable the run.processes.with.pty option.
>On a related but not important issue, MSVC also shows the annoying popup alert. I know this is not a jetbrains issue but is there a way to turn that off in Clion?
It seems there is no way to change it from CLion side.
Thanks for the suggestion. I tried it and didn't see any difference.
Apparently adding a bunch of ugly MSCV code and a platform check to my program is the way to achieve portability.
https://stackoverflow.com/questions/13943665/how-can-i-disable-the-debug-assertion-dialog-on-windows
I'll stick with what works so I can focus on learning C programming for now and learn MSVC later ;-)
Just in case, disabling PTY was suggested for Cygwin case. But I'm glad you found the solution!
Oh, OK.
This did make the output show up for cygwin. Thanks