0

I was working with Dev-Cpp with my TDM-GCC 4.9.2 64-bit Release. But suddenly got stuck in printing long double values.

     #include<stdio.h>
     void main(){
     long double a = 22.0/7.0;
     printf("%Lf",a);
}

It compiled well. Then when I ran it it said : "Error 216: This version of %1 is not compatible with the version"

What should I do?

I am not such a good programmer. If you would put some explanations and help me fix this I would be grateful

  • 2
    TDM-GCC is based on MinGW which doesn't properly support `long double`. At least this was the case a few years ago, I don't know if it's changed. – interjay Feb 06 '19 at 16:28
  • You might need to define the `__USE_MINGW_ANSI_STDIO` macro as `1`, e.g. by adding `#define __USE_MINGW_ANSI_STDIO 1` before `#include `, or by compiling with the `-D__USE_MINGW_ANSI_STDIO=1` option (the `=1` part can be omitted as that is the default for a macro defined by the `-D` option). – Ian Abbott Feb 06 '19 at 16:50
  • regarding: `void main(){` in C, there are only two valid signatures for `main` they are: `int main( void )` and `int main( int argc, char *argv[] )` Unfortunately, visual studio allows code that is not valid C. – user3629249 Feb 07 '19 at 00:12
  • regarding: `printf("%Lf",a);` The C language is case sensitive. so `lf` is valid, but `Lf` is not – user3629249 Feb 07 '19 at 00:13
  • How do I fix this? Is it my fault or the compiler's? – Kabir Uddin Feb 07 '19 at 00:57
  • @user3629249 Disagree with [only 2](https://stackoverflow.com/questions/54558150/printing-long-double-goes-wrong#comment95927823_54558150). C specifies `int main(void)`, `int main(int argc, char *argv[])`, or equivalent or in some other implementation-defined manner. C11 §5.1.2.2.1 1 – chux - Reinstate Monica Feb 07 '19 at 02:08
  • @user3629249 OP's `"%Lf"` is valid and matches `long double` since C99. The compiler is suspect. – chux - Reinstate Monica Feb 07 '19 at 02:10
  • @chux I agree, the compiler being used by the OP is not upto date. so the `%Lf` is not valid for that compiler And `void main()` has always been invalid – user3629249 Feb 07 '19 at 02:21

0 Answers0