[CMake] Autotools->cmake: Are these checks really needed anymore?

Roger Leigh rleigh at codelibre.net
Sat Aug 30 17:56:45 EDT 2014


On Sat, Aug 30, 2014 at 04:30:15PM +0200, Rolf Eike Beer wrote:
> Am Samstag, 30. August 2014, 09:18:26 schrieb Richard Shaw:
> 
> > #AC_C_RESTRICT
> > #AC_C_VOLATILE
> 
> I'm not sure if you should even think of using them. Especially volatile is 
> often something that means "you are doing something scary".

If you're a strict C99 programmer, you might well be using restrict
routinely.  I certainly did before I migrated to mainly using C++,
and if you look at the prototypes used by e.g. glibc you'll see
restrict is used throughout.

volatile is a little more scary, but you might well find you need
it e.g. in signal handlers.


The merits of either aside, these are standard language features
and like all the other features in the list, they will be present
if you're using a conforming compiler.  As someone who made the
same switch from autotools to cmake last year (and who wrote some
of the C99 checks for autoconf in the first place!), I can't help
but feel that autoconf is still trying to solve portability
problems from two decades ago which have now been long solved.  I
stopped worrying about these details--all current compilers (modulo
MSVC and C99 support) support all these features, so unless you
really care about some long obsolete unsupported system, all this
stuff is wasted effort except for maybe <cstdint>/<stdint.h> in
which case you can do something like:

https://github.com/openmicroscopy/bioformats/blob/develop/cpp/lib/ome/compat/cstdint.h
https://github.com/openmicroscopy/bioformats/blob/develop/cpp/lib/ome/compat/config.h.in
https://github.com/openmicroscopy/bioformats/blob/develop/cpp/cmake/CompilerChecks.cmake


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


More information about the CMake mailing list