analogdevicesinc / libiio

A cross platform library for interfacing with local and remote Linux IIO devices
http://analogdevicesinc.github.io/libiio/
GNU Lesser General Public License v2.1
484 stars 312 forks source link

codebase isn't c99 compliant? (double underscore reserved words?) #474

Closed rgetz closed 4 years ago

rgetz commented 4 years ago

I noticed when turning on more warnings on clang, that C99 states:


7.1.3 Reserved identifiers

Each header declares or defines all identifiers listed in its associated subclause, and optionally declares or defines identifiers listed in its associated future library directions subclause and identifiers which are always reserved either for any use or for use as file scope identifiers.

The libc doc says similar things:


1.3.3 Reserved Names

reserved names include all external identifiers (global functions and variables) that begin with an underscore (‘_’) and all identifiers regardless of use that begin with either two underscores or an underscore followed by a capital letter are reserved names. This is so that the library and header files can define functions, variables, and macros for internal purposes without risk of conflict with names in user programs.


We could read that as those are instructions for applications, and don't apply to libraries, like libiio, but I'm not sure C99 was written like that...

We use double underscore alot (__api, etc) in iio.h

More info can be found here

It's not hard to change (a couple minutes of sed), but it's alot of churn...

 bindings/matlab/iio-wrapper.h |   12 -
 dns_sd_avahi.c                |    6 
 examples/ad9361-iiostream.c   |    2 
 examples/ad9371-iiostream.c   |    4 
 examples/adrv9009-iiostream.c |    4 
 examples/dummy-iiostream.c    |    4 
 iio-private.h                 |   18 +-
 iio.h                         |  314 ++++++++++++++++++++----------------------
 libini/ini.h                  |   24 +--
 man/make_man.sh               |    2 
 10 files changed, 197 insertions(+), 193 deletions(-)
tfcollins commented 4 years ago

This seems kinda nitpicky to me. IMHO if we get a name clash fix it then.

dNechita commented 4 years ago

This seems kinda nitpicky to me. IMHO if we get a name clash fix it then.

I'm afraid that will never get a name collision but an undefined behavior instead. This guy https://www.youtube.com/watch?v=0vJXQ2VOzEs explains this much better. I know it' about C++ but I think the concept is the same.

rgetz commented 4 years ago

"undefined behavior" in that context is a name clash.

the compiler should throw an error about things being redefined.

rgetz commented 4 years ago

I think I will close as "Won't fix" as not many people care (until there is a problem).