Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Problems with Eclipse Kepler(Code won't run, no error messages)
Problems with Eclipse Kepler [message #1754617] Tue, 21 February 2017 01:04 Go to next message
Eclipse UserFriend
I'm currently enrolled in a class where I am just beginning to learn how to code C/C++ so I downloaded Eclipse Kepler to use as my IDE. I have lots of trouble just trying to get it to run, but after several days of trying many solutions and getting it to accept my code without giving me an error on every line, now it simply won't run the code.

I am using the examples from my textbook and I've run the code in Visual Studio so I know the problem isn't with the code. I can get a puts() function to work and the output works fine. But if I add a scanf() funtion to accept user input, the console just goes blank but keeps running like it's trying to load something but nothing ever happens. I go into the Problems window and it doesn't show anything. Then if I comment out the scanf() function it continues to not load until after I close Eclipse and open it again.

I've looked this up and I can't seem to find anyone else with a similar problem. I'm very new to this IDE and this programming language so I have no clue what is going wrong or how to proceed.
Re: Problems with Eclipse Kepler [message #1754725 is a reply to message #1754617] Tue, 21 February 2017 14:33 Go to previous messageGo to next message
Eclipse UserFriend
Why compiler are you using? If it's MinGW on Windows, make sure you have your MinGW bin path. Also, there might be buffering going on, for some workarounds see https://bugs.eclipse.org/bugs/show_bug.cgi?id=173732#c38 and later comments.
Re: Problems with Eclipse Kepler [message #1754743 is a reply to message #1754725] Tue, 21 February 2017 16:37 Go to previous messageGo to next message
Eclipse UserFriend
The following works with NEON under Windows 7 using MinGW.
I tried setvbuf with no buffering (_IONBF) but there is still some buffering occurring.
According to the bug report this is likely the buffer in the pipe between eclipse and the executable.
I normally use _IOLBF myself but it had a strange effect.
You should flush after every prompt.

int main(void) {
//	setvbuf(stdout, NULL, 0, _IOLBF);
	puts("!!!Hello World!!!\n");
	int integer1;
	int integer2;
	int sum;
	printf("Starting program\n");     fflush(stdout);
	printf("Enter first  integer: "); fflush(stdout);
	scanf("%d", &integer1);

	printf("Enter second integer: "); fflush(stdout);
	scanf("%d", &integer2);

	sum = integer1 + integer2;

	printf("Sum is:               %d\n", sum);
	printf("Done\n");

	return EXIT_SUCCESS;
}


Did you pick Kepler for a reason.? The latest is NEON.2. Why not use it?

[Updated on: Tue, 21 February 2017 16:40] by Moderator

Re: Problems with Eclipse Kepler [message #1754879 is a reply to message #1754725] Thu, 23 February 2017 07:52 Go to previous messageGo to next message
Eclipse UserFriend
I have the MinGW bin folder in my PATH and .gdbinit is already the GDB command file in the Debug Configuration.
Re: Problems with Eclipse Kepler [message #1754881 is a reply to message #1754743] Thu, 23 February 2017 07:59 Go to previous messageGo to next message
Eclipse UserFriend
I picked Kepler because Mars.2 didn't have the option to compile C/C++ that I could find so I searched for an Eclipse compiler that did an Kepler was the first one to come up. Would Neon.2 be easier to work with?

I added fflush(stdout); to the end of every line where there is a prompt and suddenly the code runs how it's supposed to. I'm still a noob so I'm not really sure how that works but I'm grateful it's working. But still, if there is an IDE I could use or a setting I could change that would make it so I wouldn't need to add in that extra code, that would be great. I'm still just trying to learn C so I'd like to simplify things as much as possible.
Re: Problems with Eclipse Kepler [message #1754896 is a reply to message #1754881] Thu, 23 February 2017 11:48 Go to previous message
Eclipse UserFriend
Eclipse doesn't come with a compiler. That's what MinGW provides.
You need Eclipse with a CDT plugin. Apparently, the Mars.2 you tried didn't include CDT.
The latest CDT and NEON have many bug fixes that you'll eventually want to have.

You can download the latest CDT from here:
https://eclipse.org/cdt/downloads.php

The following has the latest stable Eclipse (Neon) with CDT 9.2
http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/neon2

fflush empties the stream buffer: http://www.cplusplus.com/reference/cstdio/fflush/
It's good practice to ensure the buffer is empty after each prompt.
This is particularly true if the program is to be used with different OS environments.

If you really are annoyed with writing fflush(stdout) after every prompt you could create a function which writes the prompt; flushes the buffer; then collects the input.
It would likely involve using vprintf: http://www.cplusplus.com/reference/cstdio/vprintf/
You could modify the example given.
How to do that is off-topic for this forum but you might find out how or even a better fit by searching google.


[Updated on: Thu, 23 February 2017 19:10] by Moderator

Previous Topic:Import and build a Makefile project
Next Topic:Concept for finding Struct definitions in external header files
Goto Forum:
  


Current Time: Sat Apr 26 08:24:21 EDT 2025

Powered by FUDForum. Page generated in 0.05629 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top