Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hey, leave C++ out of this. This is a C problem.

https://en.cppreference.com/w/cpp/feature_test




That only works for language features though, it doesn't allow detecting OS/library features.


Very true, but don’t forget that Autoconf checks for “interesting” compiler choices as well as library and OS features. And then there is libtool, which abstracts out the differences between how compilers generate shared libraries so that you only have to understand one way of doing it and it will work on all of them.


Autoconf lets you check for all sorts of things:

  - instruction set architecture
  - OS versions
  - ABIs
  - libraries (whether they are installed)
    - and what functionality they provide
  - commands/executables
  - anything you can write a macro to check
All stuff too disparate to reliably have the OS be able to answer every question you might have about it and the stuff installed on it. You can't wait for any such system to learn how to answer the questions you might have about it, so some things you can only detect, either at build configuration time, build time, or run time.


https://en.cppreference.com/w/cpp/preprocessor/include

__has_include and other compile-time checking would work here (eg type_traits and enable_if)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: