Comments (9)
Apparently this was deprecated in C++-2014 and deleted in C++-2017:
https://stackoverflow.com/questions/56001160/how-do-i-replace-stdbinary-function-with-something-else-without-pain
from nco.
I can replace the <binary_function> in NcapVector.hh but what to do about it in antlr/CharScanner.hpp ?
I've checked some of the anltr2 releases for it and 2.7.7 was the last release.
Not sure what to suggest ? Can you try compiling it with clang++ again with -std=c++11 ?
On my linux box with clang version 14 it compiled fine with "-std==c++14"
from nco.
Please remove binary_function
from any NCO source code (i.e., NcapVector.hh
), since it is C++-17 incompatible. As for the Antlr headers, that's a sticky wicket. If CharScanner.hpp
is a statice file than "comes with Antlr" then perhaps you can replace binary_function
in the same way, If, on the other hand, CharScanner.hpp
itself is built during the Antlr compilation, then we're stuck and will likely need to start pinning the NCO C++ compiler to use C++-14 or earlier. Please let me know what you discover.
from nco.
As explained here, GCC g++ -std=c++17
keeps binary_function
in std::
namespace because it is standards-conformant to keep deprecated functions there. GCC will print an appropriate WARNING with -Wdeprecated
. Clangv16 appears to completely remove the function from std::
namespace.
Invoking Clangv16 with clang++ -std=c++14
does successfully compile (with WARNINGs) the relevant NCO code, whereas -std=c++17
simply fails. Here's -std=c++14
:
zender@spectral:~/nco/src/nco++$ clang++ -std=c++14 -DHAVE_CONFIG_H -I. -I../.. -I./ -I../nco -I/opt/netcdf/include -I/opt/homebrew/include -I/opt/netcdf/include -I/opt/netcdf/include -I/opt/homebrew/include -I/Users/zender/include -I/opt/homebrew/Cellar/gsl/2.7.1/include -g -Wall -DNCO_ABORT_ON_ERROR -MT Invoke.o -MD -MP -MF .deps/Invoke.Tpo -c -o Invoke.o Invoke.cc
In file included from Invoke.cc:13:
In file included from ./libnco++.hh:22:
In file included from ./fmc_cls.hh:13:
In file included from ./vtl_cls.hh:11:
In file included from ./ncap2_utl.hh:59:
./prs_cls.hh:93:48: warning: all paths through this function will call itself [-Winfinite-recursion]
prs_cls operator= (const prs_cls &prs_cpy) {
^
In file included from Invoke.cc:13:
In file included from ./libnco++.hh:26:
./fmc_gsl_cls.hh:49:11: warning: 'NCO_GSL_VERSION' macro redefined [-Wmacro-redefined]
# define NCO_GSL_VERSION ( NCO_GSL_MAJOR_VERSION * 100 + NCO_GSL_MINOR_VERSION * 10 + NCO_GSL_PATCH_VERSION )
^
../../config.h:443:9: note: previous definition is here
#define NCO_GSL_VERSION 207
^
In file included from Invoke.cc:14:
In file included from ./ncoLexer.hpp:10:
/Users/zender/include/antlr/CharScanner.hpp:65:74: warning: 'binary_function<std::string, std::string, bool>' is deprecated [-Wdeprecated-declarations]
class ANTLR_API CharScannerLiteralsLess : public ANTLR_USE_NAMESPACE(std)binary_function<ANTLR_USE_NAMESPACE(std)string,ANTLR_USE_NAMESPACE(std)string,bool> {
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__functional/binary_function.h:24:29: note: 'binary_function<std::string, std::string, bool>' has been explicitly marked deprecated here
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__config:796:41: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX11'
# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__config:781:49: note: expanded from macro '_LIBCPP_DEPRECATED'
# define _LIBCPP_DEPRECATED __attribute__((deprecated))
^
3 warnings generated.
zender@spectral:~/nco/src/nco++$
Here's -std=c++17
:
zender@spectral:~/nco/src/nco++$ clang++ --version
Homebrew clang version 16.0.1
Target: arm64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
zender@spectral:~/nco/src/nco++$ clang++ -std=c++17 -DHAVE_CONFIG_H -I. -I../.. -I./ -I../nco -I/opt/netcdf/include -I/opt/homebrew/include -I/opt/netcdf/include -I/opt/netcdf/include -I/opt/homebrew/include -I/Users/zender/include -I/opt/homebrew/Cellar/gsl/2.7.1/include -g -Wall -DNCO_ABORT_ON_ERROR -MT Invoke.o -MD -MP -MF .deps/Invoke.Tpo -c -o Invoke.o Invoke.cc
In file included from Invoke.cc:13:
In file included from ./libnco++.hh:22:
In file included from ./fmc_cls.hh:13:
In file included from ./vtl_cls.hh:11:
In file included from ./ncap2_utl.hh:54:
./NcapVector.hh:23:33: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
struct less_mag : public std::binary_function< T, T, bool>
~~~~~^~~~~~~~~~~~~~~
__binary_function
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
In file included from Invoke.cc:13:
In file included from ./libnco++.hh:26:
./fmc_gsl_cls.hh:49:11: warning: 'NCO_GSL_VERSION' macro redefined [-Wmacro-redefined]
# define NCO_GSL_VERSION ( NCO_GSL_MAJOR_VERSION * 100 + NCO_GSL_MINOR_VERSION * 10 + NCO_GSL_PATCH_VERSION )
^
../../config.h:443:9: note: previous definition is here
#define NCO_GSL_VERSION 207
^
In file included from Invoke.cc:14:
In file included from ./ncoLexer.hpp:10:
/Users/zender/include/antlr/CharScanner.hpp:65:74: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
class ANTLR_API CharScannerLiteralsLess : public ANTLR_USE_NAMESPACE(std)binary_function<ANTLR_USE_NAMESPACE(std)string,ANTLR_USE_NAMESPACE(std)string,bool> {
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
__binary_function
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
^
1 warning and 2 errors generated.
zender@spectral:~/nco/src/nco++$
from nco.
see my PR hmb-clang16-fix
Well CharScanner.hpp is static and is part of the antlr2 C++ runtime; and is used in ncoLexer.hpp.
I don't know what to suggest here ? Either we ask users to compile with the -std=c++14 flag or we modify the antlr2 runtime and have our own custom repo ?
BTW with cmake you can specify C++14 with a keyword.
from nco.
Thanks for handling the NCO end of this. Let me try to be more precise: Can you create a patch to the Antlr2 source code that deprecates reliance on std::binary_function
, and that allows the rest of Antlr2 and NCO to compile/run normally with -std=c++17? Hopefully the patch would just modify CharScanner.hpp
.
from nco.
@czender
Not sure where you are headed with this ?
anyway have added a shell script with an appropriate sed substitution.
its called src/nco++/antlrCharScannerModify.sh
Its in my PR
I see you already have a custom antlr2 repo - nco/antlr2 !!
from nco.
@hmb1
I had intended you to write, if possible, a patch for Antlr2 similar to this one
That we can upstream and distribute to Homebrew and Conda-forge and anyone else interested in building NCO with -std=c++17 or later with Clang.
So, is it possible to patch the Antlr2 source code so that Antlr2 will not include the deprecated std::binary_function
?
If so, please submit a patch to the NCO Antlr2 repository above.
from nco.
This all appears to work with NCO 5.1.9, please re-open if not.
from nco.
Related Issues (20)
- upgrade new version with apt HOT 1
- 60x compression! HOT 16
- ncap2 make_bounds exceeded memory limit HOT 1
- ncatted not honoring pre-existing history global attribute HOT 4
- x10 error margin for the same spell after HOT 6
- Unable to enable UDUNITS, not UDUNITS2 HOT 8
- No man page for ncz2psx HOT 2
- Error trying to concatenate a number of nc files HOT 5
- ncrcat adds erroneous(?) variable attribute HOT 1
- Parallelize compression over chunks? HOT 2
- ncremap pure pressure vertical interpolation does only the first timestep, everything else is zeros HOT 3
- ncap2 ignores "--cmp" when new dimensions are defined HOT 7
- nco fails to build when compiling with "--no-undefined -Wl" as ld flags HOT 1
- Error building NCO 5.1.6 with icc (Intel classic) in nco_rgr.c HOT 1
- Undefined reference when disbaling OpenMP and using the Intel compiler HOT 1
- Support NC_STRING HOT 6
- using ```ncrename``` generates a corruped file HOT 1
- Feature Request: arbitrary suffix for -n
- Need to update "--monotonic" argument for mbtempest HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nco.