Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse Luna, MinGW-w64 -- C++11 <random>(Eclipse doesn't recognize C++11 random)
Eclipse Luna, MinGW-w64 -- C++11 <random> [message #1403771] Sat, 26 July 2014 15:21 Go to next message
Kamil Saigol is currently offline Kamil SaigolFriend
Messages: 7
Registered: July 2014
Junior Member
Under newly-released Luna and new CDT for Windows x64 with MinGW-W64 (tried two different compilers) 4.8.2, Eclipse does not seem to index the <random> header. Using the code below results in red squigglies with messages:

1) "Type 'std::random_device' could not be resolved"
2) "Symbol 'uniform_int_distribution' could not be resolved"

However, the program DOES build and run in Eclipse.

C++11 support is enabled via Dialect option. I also tried the old way with both -std=c++0x and -std=c++11.

The program compiles and outputs correctly when compiled on the command line. It also works using QTCreator pointing to the same compiler. No errors are reported in either case.

#include <iostream>
#include <random>

int main()
{
    std::random_device rng;
    std::uniform_int_distribution<> uid(1, 10);

    for(std::size_t i = 0; i < 10; i++)
    {
        std::cout << uid(rng) << " ";
    }
    std::cout << std::endl;

    return 0;
}


Am I doing something wrong?

Thanks
Re: Eclipse Luna, MinGW-w64 -- C++11 <random> [message #1403806 is a reply to message #1403771] Sun, 27 July 2014 20:53 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Hello Kamil,

disable Codan (Code Analysis) to remove the warnings:

http://wiki.eclipse.org/CDT/User/NewIn70#Code_Analysis

You also could check bugzilla if this problem is already known:

https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced;component=cdt-codan;bug_status=UNCONFIRMED;bug_status=NEW;bug_status=ASSIGNED;bug_status=REOPENED;product=CDT;classification=Tools

regards,
Klaus


Re: Eclipse Luna, MinGW-w64 -- C++11 <random> [message #1403886 is a reply to message #1403806] Mon, 28 July 2014 13:04 Go to previous messageGo to next message
Kamil Saigol is currently offline Kamil SaigolFriend
Messages: 7
Registered: July 2014
Junior Member
Hi Klaus,

Thank you for the reply.

Disabling code analysis isn't a great solution, so back to Kepler for now.

It doesn't look like there is an open bug for this so I will file one and post the link here.

Thanks

Edit: https://bugs.eclipse.org/bugs/show_bug.cgi?id=440558

[Updated on: Mon, 28 July 2014 14:23]

Report message to a moderator

Re: Eclipse Luna, MinGW-w64 -- C++11 <random> [message #1403918 is a reply to message #1403886] Mon, 28 July 2014 15:07 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Hi Kamil,

Quote:
Disabling code analysis isn't a great solution, so back to Kepler for now.


i get the same errors with Kepler. I'm wondering, why this does not happen with Kepler in your workspace. Maybe you already have disabled Codan in Kepler?

Thanks for the bugzilla link.

regards,
Klaus



Re: Eclipse Luna, MinGW-w64 -- C++11 <random> [message #1403932 is a reply to message #1403918] Mon, 28 July 2014 16:01 Go to previous messageGo to next message
Kamil Saigol is currently offline Kamil SaigolFriend
Messages: 7
Registered: July 2014
Junior Member
Klaus,

That is strange. I have brand-new, completely untouched Kepler and Luna in exactly the same environment. Code analysis seems to be enabled in both versions. Kepler doesn't give me an error; Luna does.

The only difference between the two is the path, but since they live side-by-side it shouldn't make a difference.

D: --> dev --> eclipse_kepler --> eclipse --> eclipse.exe
D: --> dev --> eclipse_luna --> eclipse --> eclipse.exe
Re: Eclipse Luna, MinGW-w64 -- C++11 <random> [message #1403952 is a reply to message #1403932] Mon, 28 July 2014 17:11 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Quote:
I have brand-new, completely untouched Kepler and Luna


I used (Windows 7, btw.)

Luna: Eclipse Platform Version 4.4.0 and CDT Version 8.4.0
Kepler: Eclipse Platform Version 4.3.2 and CDT Version 8.3.0

and get the same error with both versions.

Quote:
Code analysis seems to be enabled in both versions


Hm, could you compare the Codan settings in both projects?

There are two locations for the settings.

General:
Windows -> Preferences -> C/C++ -> Code Analysis

Project-specific:
Project -> Properties -> C/C++ General -> Code Analysis

regards,
Klaus


Re: Eclipse Luna, MinGW-w64 -- C++11 <random> [message #1404517 is a reply to message #1403952] Sat, 02 August 2014 18:44 Go to previous message
Kamil Saigol is currently offline Kamil SaigolFriend
Messages: 7
Registered: July 2014
Junior Member
Hi Klaus,

Apologies for the delay -- away for work for a few days with no access to a Windows PC.

Codan settings were identical. However, I know why I was getting different results. Kepler wasn't "completely untouched" as I had said -- in fact, I had added the -std=c++11 flag to the "Command to get compiler specs" (workspace-wide) the previous night and then forgotten about it. All other settings are the same.

Please also see my latest post on the bugzilla. This seems to solve the problem in Luna and in Kepler -- however, I find it strange that it is necessary with the new "Dialect" option. Nonetheless, there it is.

Thanks for your help!

[Updated on: Sat, 02 August 2014 18:46]

Report message to a moderator

Previous Topic:Index and AST connection
Next Topic:C++11 CMake based project no support in indexer
Goto Forum:
  


Current Time: Thu Oct 03 23:07:20 GMT 2024

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

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

Back to the top