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

Add std::basic_stringbuf::view() (IDFGH-14044) #14865

Closed
Mis1eader-dev opened this issue Nov 11, 2024 · 9 comments
Closed

Add std::basic_stringbuf::view() (IDFGH-14044) #14865

Mis1eader-dev opened this issue Nov 11, 2024 · 9 comments
Labels
Status: Opened Issue is new Type: Feature Request Feature request for IDF

Comments

@Mis1eader-dev
Copy link

Is your feature request related to a problem?

basic_stringbuf has the method str() that dumps the internal buffer into a newly allocated string.

However, it does not seem to have view(), which is a view into said internal buffer. It is part of the C++ standard.

Describe the solution you'd like.

Have a way to view the internal buffer.

Describe alternatives you've considered.

Tried to create classes inheriting from those super classes, however it's not possible as pptr, egptr, and pbase are protected member variables of basic_stringbuf.

Additional context.

No response

@Mis1eader-dev Mis1eader-dev added the Type: Feature Request Feature request for IDF label Nov 11, 2024
@github-actions github-actions bot changed the title Add std::basic_stringbuf::view() Add std::basic_stringbuf::view() (IDFGH-14044) Nov 11, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 11, 2024
@igrr
Copy link
Member

igrr commented Nov 11, 2024

@Mis1eader-dev Could you please add, which IDF version are you using? Could you share the code snippet which fails to compile and the compilation log?

As far as I can see, recent toolchains already support this: https://godbolt.org/z/jocKq7YPj. So either you are using an older version of IDF where the toolchain didn't yet support C++20, or the specific translation unit is not compiled with C++20 or later standard.

@Mis1eader-dev
Copy link
Author

@igrr I'm using platformio, and today updated the Espressif32 platform to version 6.9.0, which claims has an IDF version of 5.3.1.

I have the following compile flags and unflags:

build_flags =
	-std=gnu++2a
build_unflags =
	-std=gnu++11

@atanisoft
Copy link

@Mis1eader-dev v5.3.1 defaults to gnu++20 by default (from my testing) so your build_unflags will have zero effect. I'd expect this may turn out to be a version issue on the PIO side (it may not be using the declared compiler versions for v5.3.1) or you have something off in your platformio.ini file possibly (besides the build flags)

@igrr
Copy link
Member

igrr commented Nov 11, 2024

v5.3.1 defaults to gnu++20

Should be C++23, docs, code.

I am not very familiar with PIO build system, but I'd recommend making it print the whole compiler command line on failure and then seeing which flags are passed to the compiler. I am guessing that something sets the C++ version to a lower value than IDF's default. Maybe after looking at the compiler command line you can find where that happens.

@atanisoft
Copy link

atanisoft commented Nov 11, 2024

Even better if it defaults to 23 now :)

EDIT: looks like the docs are claiming gnu++23 but the code uses gnu++2b, a minor difference but required from GCC side (for now) but LLVM supports both c++2b and c++23

@atanisoft
Copy link

@Mis1eader-dev Looking at the actual versions that PIO is pulling in a much older version of GCC than included by ESP-IDF v5.3.1: https://github.com/platformio/platform-espressif32/blob/268f561df4793d631d02e4ff5e67b6b11d1be4ec/platform.json#L36. This looks related to their using arduino-esp32 2.x versions still for most tools.

I'm not sure if there is a good way to upgrade other than move off of platformio and use esp-idf directly.

@Mis1eader-dev
Copy link
Author

@atanisoft I looked into the project's build idedata.json and it has this entry in its "defines"

IDF_VER="v4.4.7-dirty"

With the following compiler flags

["-std=gnu++2a", "-Wno-frame-address", "-fexceptions", "-fno-rtti", "-Os", "-mlongcalls", "-ffunction-sections", "-fdata-sections", "-Wno-error=unused-function", "-Wno-error=unused-variable", "-Wno-error=deprecated-declarations", "-Wno-unused-parameter", "-Wno-sign-compare", "-ggdb", "-freorder-blocks", "-Wwrite-strings", "-fstack-protector", "-fstrict-volatile-bitfields", "-Wno-error=unused-but-set-variable", "-fno-jump-tables", "-fno-tree-switch-conversion", "-MMD"]

And seems to use GCC 8.4, just like you suggested

toolchain-xtensa-esp32\\xtensa-esp32-elf\\include\\c++\\8.4.0

@Mis1eader-dev
Copy link
Author

I'll make an issue on the other repo and link back here

@Mis1eader-dev
Copy link
Author

Found a fork of platform-espressif32, I'll try to use that instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

4 participants