Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse indexing wrongly
Eclipse indexing wrongly [message #1022322] Thu, 21 March 2013 17:11 Go to next message
David W is currently offline David WFriend
Messages: 16
Registered: March 2013
Junior Member
Hi

I posted this under different category eariler.

I've found a problem and I think it might be an eclipse bug.

I am on redhat 5 x64 running juno. The following code prints out checkpoint2. However, eclipse grayed out checkpoint1 and checkpoint2 . Appraently, eclipse uses a different ULONG_MAX value as from the gcc compiler. Is this a bug from eclipse?

#include <stdio.h>
#include <limits.h>

int main()
{
printf("%llu\n", (unsigned long long) ULONG_MAX);
/* prints 18446744073709551615 and checkpoint2 */

#if (ULONG_MAX >> 31) == 1 <---- grayed out
printf("checkpoint1\n");
#elif (ULONG_MAX >> 63) == 1 <---- grayed out
printf("checkpoint2\n");
#else
printf("checkpoint3\n");
#endif

return 0;
}
Re: Eclipse indexing wrongly [message #1022474 is a reply to message #1022322] Fri, 22 March 2013 00:06 Go to previous messageGo to next message
David W is currently offline David WFriend
Messages: 16
Registered: March 2013
Junior Member
Can someone confirm? I am not sure if I am doing something stupid...
Re: Eclipse indexing wrongly [message #1022718 is a reply to message #1022322] Fri, 22 March 2013 12:16 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
According to the MSDN help page http://msdn.microsoft.com/en-us/library/ew2hz0yd.aspx
"The translation represents type int the same as type long"

This code here will work (I tried it with gcc and Eclipse on Windows)
#if (UINT_MAX >> 31 == 1)
  dfd
#endif




Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Eclipse indexing wrongly [message #1022837 is a reply to message #1022322] Fri, 22 March 2013 16:05 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Hello David,

you probably know that Eclipse and CDT are written in Java?
The biggest integer Data Type in Java is long, which is a 64 Bit SIGNED type. This is the reason, why the Editor grayed out the 'if' wrongly, because CDT internally is using "long".

Try out this example, it's using the biggest number, which CDT (and Java) could save in a primitive Data Type "long". In this example checkpoint2 is not grayed out:

#include <stdio.h>
#include <limits.h>

#define TEST_MAX 0x7fffffffffffffffUL

int main() {
printf("%llu\n", (unsigned long long) TEST_MAX);

#if TEST_MAX == 0xffffffffUL +1
printf("checkpoint1\n");
#elif (TEST_MAX >> 62) == 1
printf("checkpoint2\n");
#else
printf("checkpoint3\n");
#endif

return 0;
}

Could you please check Bugzilla, maybe there is already a Bug-Entry about this problem, but if not please add a new bug.

Bugzilla: https://bugs.eclipse.org/bugs/

Java-Data Types: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

regards,
Klaus


Re: Eclipse indexing wrongly [message #1022869 is a reply to message #1022837] Fri, 22 March 2013 17:20 Go to previous messageGo to next message
David W is currently offline David WFriend
Messages: 16
Registered: March 2013
Junior Member
Hi Klaus

Thanks. I don't see an existing bug so I created one last week, ID 403404.

I used your example and yes the checkpoint2 is NOT grayed out.

My case is not as simple as printing out "checkpoinsts". I actually have some typedef within each if condition. Wrongly grayed out means the typedef declaration within the if statement will NOT be known and so the indexing throughout the whole program fails.

Is there a quick fix that we can do to avoid this situation?

Thanks

David

[Updated on: Fri, 22 March 2013 17:21]

Report message to a moderator

Re: Eclipse indexing wrongly [message #1022880 is a reply to message #1022869] Fri, 22 March 2013 17:59 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Quote:
Is there a quick fix that we can do to avoid this situation?


Not that I know of.

If you have a central header you could add your own define (for 32Bit/64Bit) and then use this new define in your code - but you must change your source...

regards,
Klaus


Re: Eclipse indexing wrongly [message #1022893 is a reply to message #1022880] Fri, 22 March 2013 18:35 Go to previous message
David W is currently offline David WFriend
Messages: 16
Registered: March 2013
Junior Member
Yes. Thats what I am afraid of Shocked changing the source code for this purpose. Hopefully, I can get some outlook from the Eclipse developer(s) to see when this will be fixed.
Previous Topic:"Member declaration not found" but "Open declaration" is fine!
Next Topic:Debbuger won't find library functions
Goto Forum:
  


Current Time: Thu Apr 18 08:54:53 GMT 2024

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

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

Back to the top