Opened 15 months ago

Last modified 14 months ago

#67934 assigned defect

edid-decode @20230804: error: use of undeclared identifier 'nullptr'

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: wwalexander (William Alexander)
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: Cc:
Port: edid-decode

Description

https://build.macports.org/builders/ports-10.7_x86_64-builder/builds/154784/steps/install-port/logs/stdio

edid-decode.cpp:303:22: error: no member named 'to_string' in namespace 'std'
        unsigned len = std::to_string(cta.preparsed_total_dtds).length();
                       ~~~~~^
edid-decode.cpp:601:19: error: no member named 'to_string' in namespace 'std'
                add_str(s, std::to_string(t->hsize_mm) + " mm x " + std::to_string(t->vsize_mm) + " mm");
                           ~~~~~^
edid-decode.cpp:601:60: error: no member named 'to_string' in namespace 'std'
                add_str(s, std::to_string(t->hsize_mm) + " mm x " + std::to_string(t->vsize_mm) + " mm");
                                                                    ~~~~~^
edid-decode.cpp:1652:3: error: use of undeclared identifier 'nullptr'
                nullptr
                ^
edid-decode.cpp:1662:17: error: use of undeclared identifier 'nullptr'
        if (opt_str == nullptr && opt != CVT_INTERLACED && opt != CVT_ALT &&
                       ^
edid-decode.cpp:1671:28: error: use of undeclared identifier 'nullptr'
                *value = strtod(opt_str, nullptr);
                                         ^

The mention of nullptr makes clear that this software requires C++11, and the compiler hasn't been told to use C++11 mode.

The solution will probably be something like:

compiler.cxx_standard 2011
configure.cxxflags-append -std=c++11

Change History (6)

comment:1 Changed 15 months ago by wwalexander (William Alexander)

I've updated the Portfile with the suggested lines. What's the best way if any to test the behavior on older systems? Thank you for the guidance!

comment:2 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)

You can test on older systems using an older Mac or a virtual machine running on a newer Mac. But even though I have both of these I usually don't bother. If a change seems likely to fix a problem, I often just commit it and later check to see if that fixed the build on the buildbot. I like monitoring the buildbot waterfall but build status eventually makes its way into the ports web site too.

comment:3 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to wwalexander
Status: newassigned

See my comment above.

Also, sometimes you don't need an older system to verify a fix. For example, here we know nullptr is a C++11 feature, so we need to ensure a C++11 compiler is used and that it is told to be in C++11 mode.

compiler.cxx_standard 2011 ensures the former, presuming that the build system correctly uses CXX to invoke the C++ compiler. You can test whether this is the case on any OS version by doing a build and specifying a nonstandard compiler, for example sudo port build edid-decode configure.compiler=macports-clang-16, then greping through the log to make sure that every compilation happened via that compiler (/opt/local/bin/clang++-mp-16).

configure.cxxflags-append -std=c++11 ensures the latter, presuming that the build system correctly passes CXXFLAGS to every C++ compiler invocation. You can test whether this is the case on any OS version by doing a build and then greping through the log for any occurrences of bin/clang++ that do not also include -std=c++11. Looking at the project's Makefile, it looks like it does not use CXXFLAGS; it erroneously passes CFLAGS to the C++ compiler. Upstream should fix this.

Upstream should also be adding -std=c++11 to CXXFLAGS in the Makefile without us having to do it.

comment:4 Changed 14 months ago by William Alexander <wwalexander@…>

In f3e38e7d0197030e11bf55f81175fe22a0a2ab26/macports-ports (master):

edid-decode: fix Portfile whitespace

  • add blank line after modeline as specified by port lint --nitpick
  • move destroot args to separate lines

References: #67934

comment:5 Changed 14 months ago by William Alexander <wwalexander@…>

In 497f2b14cc269a4dc7479b0be99a3a3d43644493/macports-ports (master):

edid-decode: specify C++ 2011 standard

  • patch Makefile to use CXXFLAGS instead of CFLAGS
  • specify C++ 2011 to support building on older machines

References: #67934

comment:6 Changed 14 months ago by wwalexander (William Alexander)

This should be fixed by https://github.com/macports/macports-ports/pull/20270. Could you verify?

Note: See TracTickets for help on using tickets.