Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with std::string_view #3

Closed
RisingLiberty opened this issue Oct 27, 2020 · 6 comments
Closed

Not working with std::string_view #3

RisingLiberty opened this issue Oct 27, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@RisingLiberty
Copy link

code:
#include <string_view>

void f()
{
std::string_view name, prefix, suffix;
}

struct MyStruct
{
int x, y, z;
};

output:
[19:23:57] Looking for structures at D:\C++\Testing\TestCode\TestCode\src\struct_layout.cpp:8:11...
[19:23:57] COMMAND LINE: D:\C++\Testing\TestCode\TestCode\src\struct_layout.cpp -- -x c++ -m64 -w -DFORCE_STATIC_VCRT -D_MBCS -ID:\C++\Testing\TestCode\TestCode\SDL\ -ID:\C++\Testing\TestCode\TestCode\include
[19:23:57] Execution Log:
D:\C++\Testing\TestCode\TestCode\src\struct_layout.cpp:5:7: error: no type named 'string_view' in namespace 'std'
std::string_view name, prefix, suffix;
~~~~~^
1 error generated.
Error while processing D:\C++\Testing\TestCode\TestCode\src\struct_layout.cpp.

[19:23:57] [ERROR] Unable to scan the given location. (37.0765 ms)

@Viladoman
Copy link
Owner

Viladoman commented Oct 27, 2020

Gladly I could quickly reproduce in a simple test project.
The issue is that std::string_view is a C++17 feature and by default the parser is using C++14 (afaik).

As a workaround you could try to go to the Struct Layout options and add this:
image

The options are at the bottom-left of the Struct Layout Tool Window.

I will keep this issue open as I think it might be interesting to capture the c++ standard version automatically from the Project properties.

Let me know if this fixes it!

@RisingLiberty
Copy link
Author

yea I figured that was it, good luck getting it from the project settings, VS extension dev is a pain :p

@lukaasm
Copy link

lukaasm commented Oct 28, 2020

Gladly I could quickly reproduce in a simple test project.
The issue is that std::string_view is a C++17 feature and by default the parser is using C++14 (afaik).

As a workaround you could try to go to the Struct Layout options and add this:
image

The options are at the bottom-left of the Struct Layout Tool Window.

I will keep this issue open as I think it might be interesting to capture the c++ standard version automatically from the Project properties.

Let me know if this fixes it!

The problem with that is, you need to have open Struct Layout Window first which doesn't happen when there are parsing errors.

As a workaround you need to go/create a standalone file without any includes, create struct and PPM to open Struct Layout Window. And now you can open settings and add additional args.

It would be awesome if extension contributed additional toolbar button/VS Settings entry for easier access to tool options.

@Viladoman Viladoman added the bug Something isn't working label Oct 28, 2020
@Viladoman
Copy link
Owner

I just submitted version 0.2.2 which should autodetect the language version from the project configuration.

@lukaasm I think adding a command for the options directly in the Tools tab is a good idea, I will do it. As a workaround, without having to create an empty file, you can open the tool window directly here:

image

Let me know if the issue got fixed at your end.

@RisingLiberty
Copy link
Author

Yep, seems to work now, thanks! :)

@Viladoman
Copy link
Owner

Awesome! Thanks for verifying it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants