Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Invalid template arguments for std::vector<std::string>(Indexer)
Invalid template arguments for std::vector<std::string> [message #1835808] Sun, 13 December 2020 23:24 Go to next message
Claude Robitaille is currently offline Claude RobitailleFriend
Messages: 4
Registered: December 2020
Junior Member
I love my code to be clean and the editor reporting no errors and/or warnings. However I am in a situation where I have 100s of errors and warnings. Specifically a lot of
- invalid template arguments
- field 'xyz' could not be resolved and
- method 'abc' could not be resolved

In this post I'd like to focus on the first issue, the 'invalid template arguments' as it happens even with some of the basic std containers and thus may explain some of the other errors. In the following code, cdt's editor reports that std::vector has an invalid template argument. I can change std::string to int or char or whatever and the result is the same. std::list, though, is fine.


#include <vector>
#include <string>

std::vector<std::string> var1;
std::list<std::string> var2;

I am using my own make files and cross compile using gcc. The crosscompiler is in the project directory tree so when pressing on F3 I can navigate to every definition needed.

I am not sure where to start looking for a resolution. Any pointer would be appreciated.

Re: Invalid template arguments for std::vector<std::string> [message #1835813 is a reply to message #1835808] Mon, 14 December 2020 05:20 Go to previous messageGo to next message
David VavraFriend
Messages: 1430
Registered: October 2012
Senior Member
I use vectors of strings a lot.
They work fine for me.

Could you post the exact text (copy and paste) of the first couple of errors?

  • Are the the includes flagged like the #include<NOSUCH> below?
    index.php/fa/39538/0/
  • Does the code compile?
    It could be you have a missing brace or other bad syntax.
  • What is the prefix for the cross-compile?
  • Are you sure you are using the proper compiler builtins?

It's odd that std::list<std::string> var2 works for you without including <list>
Is the code you've posted the actual code with the problem?
index.php/fa/39541/0/

FWIW: Here's a complete program (not cross compiled)
index.php/fa/39542/0/

[Updated on: Mon, 14 December 2020 05:40]

Report message to a moderator

Re: Invalid template arguments for std::vector<std::string> [message #1835844 is a reply to message #1835813] Mon, 14 December 2020 20:14 Go to previous messageGo to next message
Claude Robitaille is currently offline Claude RobitailleFriend
Messages: 4
Registered: December 2020
Junior Member
After playing with some settings some of the errors come and go, including the std::vector. Frankly, since I am
not using eclipse's build capability I did not spend too much time on its configuration.

But I realise that the editor depends on the build configuration to do its magic. So, my strategy is to set eclipse
to use the native compiler. (both the native compile and the cross-compiler are gcc, which, although they may
not be at the same version are more than likely sufficiently close for my purpose).

But where to set the compiler? Is it project/properties/c-c++build/Tool Chain Editor? It certainly looks like it is
the correct place. However I still have some 3rd party open source software that still have some unresolved.
Particularly POCO, which defines internal preprocessor variables, based on, I presume, on compiler related
variable. In particular, POCO, sets the POCO_OS_FAMILY_UNIX based on "linux" being defined (or a bunch
of other alternative variable). None of the POC_OS_FAMILITY_XXX is set, which tells me that somehow eclipse
does not successfully set what ever the native compiler should be setting.

I googled to try to find a comprehensive guide to set eclipse properly. But I find is cook guide, not a real documentation
site that would describe the whole thing, including concept. My question is where can I find this information? An
example of question I would like to find the answer for is about this command eclipse uses to get the compiler spec:

${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"

where does COMMAND (and FLAGS) get set?


Thanks
Re: Invalid template arguments for std::vector<std::string> [message #1835845 is a reply to message #1835844] Mon, 14 December 2020 20:46 Go to previous messageGo to next message
David VavraFriend
Messages: 1430
Registered: October 2012
Senior Member
Even with a Makefile Project you should select a tool chain.
${COMMAND} is set to the compiler in the tool chain.
${INPUTS} is set to a C or C++ file depending on the language.
Note that it expects GCC or a derivative.

${FLAGS} is always empty for me.

Alternately, you could just replace ${COMMAND} with the appropriate compiler.
Using your native GCC should be acceptable.

The best consolidated document for setting Indexer stuff is:
https://www.eclipse.org/community/eclipse_newsletter/2013/october/article4.php

You can also enter include paths and macros manually under "User Settings Entries"
Re: Invalid template arguments for std::vector<std::string> [message #1836623 is a reply to message #1835845] Sat, 09 January 2021 19:21 Go to previous messageGo to next message
Claude Robitaille is currently offline Claude RobitailleFriend
Messages: 4
Registered: December 2020
Junior Member
Thanks, the link did help a lot for me to set things straight. I think this is an important document that should be maintained. Being able to rely on the Indexer is, IMHO, the most important feature of CDT. The build system is not so important (well, I must admit that since I do not use it I probably have a biased view....).

Since I am not using the build system and that ultimately my cross-compiler is equivalent to the native compiler, I guess I do not have to worry about CDT finding the cross-compiler. But, if I were to need CDT to access the crosscompiler, I still do not understand where to tell CDT the location of the compiler. Is it simply by adding the crosscompiler location to the PATH environment variable? If so, I think a more explicit setting should be provided; yes, it is possible to override the compiler call in the global build setting (or the corresponding in the project settings) but it is not as clean as having a specific setting for the location of the cross-compiler).

Anyway, I pretty much resolve everything except for the autogenerated protobuf include. I did add the location of the protobuf includes in C/C++ General/Pahts and Symbols / Includes for both GNU C and GNUC++. Consequently, I can navigate to the include files via pressing F3 on the include statements (so CDT definitely finds the include files). But I get an " Method XXXX could not be resolved" for every statement where I use any of the methods defined in the protobuf classes. I fact, if after entering '.' after an instance name, the popup does not list any single method. It only lists the class object, which is weird. The declaration of the instance (so typename variablename) is Ok, no error reported here. I can press F3 on the typename and get to the correct include file and class definition. Most of the methods, if not all, are defined inline in the include files generated by protobuf. The signature of the methods only use standard types (int, std::string, etc) so I think the indexer should be happy. But apparently it is not. Any ideas?
Re: Invalid template arguments for std::vector<std::string> [message #1847684 is a reply to message #1835844] Wed, 03 November 2021 15:02 Go to previous messageGo to next message
Steve Kohler is currently offline Steve KohlerFriend
Messages: 3
Registered: November 2021
Junior Member
index.php/fa/41254/0/This error is still occurring. It's also occurring for vectors of float data types.

I first noticed it yesterday (11/2/2021). And it is now happening on opening files that haven't changed since last commit to git (when none of these errors were occurring).

So it seems like something has happened in Eclipse that is causing this since my last commit on October 19 2021.

Tried rolling back eclipse to a previous installation from September in the Installation History, but that made no difference.

I've attached some screen images showing these errors which simply weren't there a week or so ago.
I looked at the document referenced in the previous replies and have to admit that I felt as though I was in way over my head, but did manage to enter a path for a compiler after doing a "which gcc" in a terminal window - can't remember how to get to that setting now (yikes!) but that didn't make any difference anyway.

I've included some screenshots of some other settings in the hopes that maybe someone will see something that could help. Starting to get worried about time lost on this - anybody have any ideas about how to fix this?
Re: Invalid template arguments for std::vector<std::string> [message #1847687 is a reply to message #1847684] Wed, 03 November 2021 15:56 Go to previous messageGo to next message
Steve Kohler is currently offline Steve KohlerFriend
Messages: 3
Registered: November 2021
Junior Member
No Message Body
Re: Invalid template arguments for std::vector<std::string> [message #1847688 is a reply to message #1847687] Wed, 03 November 2021 16:02 Go to previous messageGo to next message
Steve Kohler is currently offline Steve KohlerFriend
Messages: 3
Registered: November 2021
Junior Member
This is my temporary work around until I can come up with a better more proper solution.

Under Project Settings, C/C++ General, CodeAnalysis, uncheck the following options:
Invalid template argument,
Method cannot be resolved.

Click Apply.

Love to hear anyone's ideas for a better, less ad hoc fix :)
Re: Invalid template arguments for std::vector<std::string> [message #1847696 is a reply to message #1847688] Wed, 03 November 2021 23:32 Go to previous message
David VavraFriend
Messages: 1430
Registered: October 2012
Senior Member
Does the file compile?

[Updated on: Wed, 03 November 2021 23:32]

Report message to a moderator

Previous Topic:How to config CDT debug for cygwin?
Next Topic:Members Declaration Not Found HELP HELP HELP
Goto Forum:
  


Current Time: Mon Sep 26 06:52:45 GMT 2022

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

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

Back to the top