Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic <vector><string> compilation problem (Read 2378 times)
elotn
Newbies
*
Offline


Posts: 3
Joined: Sep 1st, 2020
<vector><string> compilation problem
Sep 2nd, 2020 at 12:26pm
Print Post  
I have problem with compilation when I'm returning <vector><string>. I made some tests and the same code compile on PlatformIO and on Arduino. It's easy to replicate problem with VisualMicro. I'm using:
Visual Studio Community 2019 16.7.2
VisualMicro PRO 2020.708.7
Arduino 1.8.13
board is OLIMEX ESP32-EVB
For me it looks like wrong vector and string is used from external dependencies. There is ArduinoSTL instead of esp.

ERROR:
VectorTest1.ino: 8:1: error: invalid use of template-name 'std::vector' without an argument list
   vector<string> test = split("test test test", " ")

CODE FOR REPLICATE PROBLEM:
#include <vector>
#include <string>

using namespace std;
vector<string> split(const string& str, const string& delim);
void setup() {

    vector<string> test = split("test test test", " ");
}

void loop() {
    // put your main code here, to run repeatedly:
}
vector<string> split(const string& str, const string& delim)
{
    vector<string> tokens;
    return tokens;
}

Please find build log and solution in attachment. Thank you for any suggestions.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2144
Joined: Feb 13th, 2019
Re: <vector><string> compilation problem
Reply #1 - Sep 2nd, 2020 at 1:32pm
Print Post  
Thanks for the detailed information and example, we are currently investigating this issue and will update when there is a workaround or fix available.

  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2144
Joined: Feb 13th, 2019
Re: <vector><string> compilation problem
Reply #2 - Sep 2nd, 2020 at 6:35pm
Print Post  
In the latest forum release (20.07.08.13) this issue should now be resolved, and it can be downloaded from the top of the below board:
https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES

If you haven't installed one of the forum releases before, further help is below:
Documentation - See Section 2. Install Visual Micro
Walkthrough Video on YouTube

Let us know if you encounter any further issues, and thanks again for the clear reporting.
  
Back to top
 
IP Logged
 
elotn
Newbies
*
Offline


Posts: 3
Joined: Sep 1st, 2020
Re: <vector><string> compilation problem
Reply #3 - Sep 3rd, 2020 at 9:35am
Print Post  
Thank you for the fast response. The main problem is solved in 20.07.08.13. I can use vector of strings as a return type. The other minor issue is that 'using' doesn't work?

When I include
#include <vector>
#include <string> 
and use:
using std::vector;
using std::string;
or using namespace std;
and
CODE:
vector<std::string> split(const std::string& str, const std::string& delim)
{
    std::vector<std::string> tokens;
    return tokens;
}


VectorTest1.ino: 7:1: error: 'vector' does not name a type
CODE:
std::vector<std::string> split(const std::string& str, const std::string& delim)
{
    std::vector<std::string> tokens;
    return tokens;
}


Compilation ok, no error

The same for string
CODE:
std::vector<string> split(const std::string& str, const std::string& delim)
{
    std::vector<std::string> tokens;
    return tokens;
}


ERROR:
VectorTest1.ino: 7:13: error: 'string' was not declared in this scope
   vector<string> split(const string& str, const string& delim)
VectorTest1.ino:7: note  suggested alternatives
 
string:39: In file included from
random:40: from
stl_algo.h:66: from
algorithm:62: from
arduino.h:142: from
VectorTest1.ino: from
Error compiling .ino project source
stringfwd.h:74: note    std  __cxx11  string
Debug build failed for project 'VectorTest1'
   typedef basic_string<char>    string
stringfwd.h:74: note    std  __cxx11  string
 
VectorTest1.ino: 7:19: error: template argument 1 is invalid
   vector<string> split(const string& str, const string& delim)
 
VectorTest1.ino: 7:19: error: template argument 2 is invalid
 
VectorTest1.ino: 11:60: error: ambiguating new declaration of 'std::vector<std::__cxx11::basic_string<char> > split(const string&, const string&)
VectorTest1.ino:7: note  old declaration int split(const string&, const string&)
   vector<string> split(const string& str, const string& delim)
 
VectorTest1.ino: In function void setup()
 
VectorTest1.ino: 14:28: error: conversion from 'int' to non-scalar type 'std::vector<std::__cxx11::basic_string<char> >' requested
   put your main code here, to run repeatedly
 
VectorTest1.ino: In function std::vector<std::__cxx11::basic_string<char> > split(const string&, const string&)
 
VectorTest1.ino: 20:75: error: ambiguating new declaration of 'std::vector<std::__cxx11::basic_string<char> > split(const string&, const string&)
VectorTest1.ino:7: note  old declaration int split(const string&, const string&)
   vector<string> split(const string& str, const string& delim)
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2144
Joined: Feb 13th, 2019
Re: <vector><string> compilation problem
Reply #4 - Sep 3rd, 2020 at 10:10am
Print Post  
Would it be possible to re-send the example solution and fresh build log (also enable the vMicro > Compile > Show Build properties as shown in the yellow box at the top)?

I'm struggling to replicate the latest issue on my machine at present, so hopefully the additional information will reveal something I'm missing.
  
Back to top
 
IP Logged
 
elotn
Newbies
*
Offline


Posts: 3
Joined: Sep 1st, 2020
Re: <vector><string> compilation problem
Reply #5 - Sep 3rd, 2020 at 10:34am
Print Post  
Sure, please find build log with enabled Build properties and example solution in attachment. I hope it helps.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: <vector><string> compilation problem
Reply #6 - Sep 3rd, 2020 at 10:00pm
Print Post  
Thanks for the output. The output shows that the serial usb deugger is enabled. Please switch the tool bar from Debug to Release to avoid use of the Serial object (which your code prevents from working)

Thank you
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint