N
N
Nordman992020-12-01 19:39:00
C++ / C#
Nordman99, 2020-12-01 19:39:00

What is wrong with Eclipse IDE?

How to set up the Eclipse IDE, maybe there are good manuals for creating C / C ++ projects in Eclipse?
The problem is this - I began to use MS Visual Studio and Eclipse IDE with a plugin for C / C ++ development for training, there are no problems in MS Visual Studio, there are always some problems with Eclipse IDE - i.e. the same programs - they compile in MSVC and then run without problems, but in the Eclipse IDE they either don’t compile, errors, then they don’t start - they throw errors, for example, take the simplest code:

#include <stdio.h>

 int main()
{ char x='w';
  printf (x);
  return (0);
}


In MSVC, it compiles without any warnings and starts by displaying the letter 'w' in the console;
in Eclipse, it immediately writes warnings opposite the lines:

int main() - return type defaults to 'int' [-Wimplicit-int] be warning?)

printf (tw); - passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
Below, during compilation, the following output is displayed in the console:

19:22:48 **** Rebuild of configuration Release for project Test_C1 ****
Info: Internal Builder is used for build
gcc -std=c99 -O3 -Wall -c -fmessage-length=0 -o "src\\Test_C1.o" "..\\src\\Test_C1.c" 
..\src\Test_C1.c:3:2: warning: return type defaults to 'int' [-Wimplicit-int]
  main()
  ^~~~
..\src\Test_C1.c: In function 'main':
..\src\Test_C1.c:5:10: warning: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
  printf (tw);
          ^~
In file included from ..\src\Test_C1.c:1:
C:/mingw64/x86_64-w64-mingw32/include/stdio.h:509:48: note: expected 'const char * restrict' but argument is of type 'char'
   int __cdecl printf(const char * __restrict__ _Format,...);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
gcc -static-libstdc++ -static-libgcc -mwindows -o Test_C1.exe "src\\Test_C1.o" 

19:22:49 Build Finished. 0 errors, 2 warnings. (took 868ms)


passing the first argument to printf makes a pointer from an integer without declaring - what the hell pointer - I instructed the command to print an already declared character variable that was assigned a value.
Well, in general, further in Eclipse everything is with the same incomprehensible difficulties, apparently something needs to be adjusted both in Eclipse itself and in the properties of the Sish project, otherwise it just won’t work right away, while in MSVC everything works right away after installation the WSWS itself and the creation of the project, there is no need to additionally configure anything, only now I want to master Eclipse more. it has a lot of plugins, cross-platform, well, many other interesting goodies.
The compiler in Eclipse is MinGW64.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2020-12-01
@Nordman99

printf("%c", x);
I missed the format string.

W
wisgest, 2020-12-02
@wisgest

Apparently, something is wrong not with the Eclipse IDE, but with MS Visual Studio. You are passing printfan argument of the wrong type. It would be correct, for example,

char x[]="w";
printf(x);

(Of course, it's even better to use putsrather than printf).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question