Suddenly my "String" definition is undefined

David Wilson 0 Reputation points
2024-01-08T07:59:38.28+00:00

Out of nowhere and for no reason I am getting "identifier String is undefined" and "Cannot resolve symbol String".

example:

String active = "active";

This is on my laptop. I'm not having the problem on my desktop. Same setup VS 2019 Enterprise, GigHub. Same code, same repository. Everything has been fine then the other day it just started happening.

I realize I can do something like: (can't remember exact syntax)

using namespace std;

#include <string>

string active = "active";

but that would change the code on the desktop when I push it to github and pull it to the desktop.... It works there without this...

Setup (both machines same):

VS 2019 Enterprise

ReSharper Ultimate 2019.3

Visual Micro

playing with Esp32-32s microcontroller (hobby thing, I'm retired lol)

I'm stumped, is this a C++ problem on the laptop? Again everythng works on the desktop...

Help?!?

:)

  • Dave
Developer technologies | C++
{count} votes

3 answers

Sort by: Most helpful
  1. David Wilson 0 Reputation points
    2024-01-08T14:27:09.84+00:00

    Thank you both for your comments.

    David:

    Yes, I can use 'string', including "using namespace std" and "<string>" but making that change will make the change on the desktop where 'String' (the String class) is working. There are a number of reasons I don't want that change on the Desktop.

    Viorel:

    I ran VS Installer and didn't find “C++/CLI support for v143”, so it wasn't installed. I did find “C++/CLI support for v142” and installed it immediately, but bringing VS backup it didn't fix my problem.

    Great thought though. This was kind of the direction I was looking for. What am I missing or what have I done wrong to break this.

    • Keep in mind that 4 days ago this was working fine and it suddenly stopped working.

    That does give me a thought though. I think I'm using the String class. so where is that defined or included? That may be what's missing...

    I really appreciate your input!

    • Dave

  2. Minxin Yu 13,501 Reputation points Microsoft External Staff
    2024-01-09T06:19:44.8966667+00:00

    Hi, @David Wilson

    String is not a C++ standard class.
    You may have used a third-party library, or the C++CLI's .NET Class String.

    After installing the C++ CLI component, make sure your project uses the /clr option. And add

    using namespace System;

    String ^ active = "active"
    User's image

    If possible, can you share your github project without personal privacy so that we can reproduce your problem.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. David Wilson 0 Reputation points
    2024-01-10T22:14:37.0833333+00:00
    Yes Minxin Yu, it's not a c++ class it's a class included with the Arduino base libraries which esp32 is dependent on.
    
    I have a resolution though.
    
    I posted a similar question in my esp forum and got my hand smacked (metaphorically) lol...
    
    The String class is huge and designed to be used by those learning micro-controllers like the Arduino which only has 32k of space. My esp32 has 520k. The String class gobbles up 21k. My software takes up ~480k including what I've reserved for my data. That leaves me bumping up near my programming limit.
    
    So I've eliminated the String class in favor of a different way to manage strings. I dropped strings altogether and went back char arrays, addresses and pointers in C where I started 40 years ago.
    
    So that's how I'm moving forward. 
    
    The answer to my question is, I was missing WString.cpp where the class is defined. I clobbered it when I manually installed an esp32 library.
    
    So thank you all for your input and direction, I really, really appreciate it!  :)
    
    I hope no one else has this problem but I guess it's out there now if someone does need it.
    
      
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.