Question header inclusion best practice

Hi all,

I'm using the C API and I'm currently using e.g.

#include <H5Tpublic.h>
#include <H5Apublic.h>
...

in order to include only what I need and nothing more. (I believe these
headers were called just H5T.h, H5A.h etc in the past BTW).

I'd just like to know if it's supported to be specific like this, or if I
can expect trouble? Should I always include the hdf5.h mega-header? (That's
what's recommended at
https://support.hdfgroup.org/HDF5/doc/H5.intro.html#Intro-Include). The
mega-header seems to just include all the _public.h headers, followed by a
few others for I/O stuff.

When it comes to the high-level API, the story seems to be a little
different. It also has _public.h headers for the modules, but the
mega-header (hdf5_hl.h) seems to pull in hdf5.h before including all the
_public.h headers, and the _public.h headers don't seem to do this on their
own. So I guess using the mega-header is definitely the recommended way for
the high-level API? (would have been nice if the _public.h were directly
includable).

Thanks in advance,
Elvis

FWIW, I think I've heard/seen other developers do this too.

That said, have you actually *measured* the impact (in terms of global symbol reduction) you are able to achieve at compile and/or link time?

Reason I ask is that its my impression that as HDF5 library is currently designed and implemented, using any one piece of it can *easily* wind up bringing in >90% of it.

Now, that is my *impression* only based on very limited examinations of executables with 'nm' tool and without really *trying* to be sure I am not doing something stupid.

Mark

"Hdf-forum on behalf of Elvis Stansvik" wrote:

Hi all,
I'm using the C API and I'm currently using e.g.
#include <H5Tpublic.h>
#include <H5Apublic.h>
...
in order to include only what I need and nothing more. (I believe these headers were called just H5T.h, H5A.h etc in the past BTW).

I'd just like to know if it's supported to be specific like this, or if I can expect trouble? Should I always include the hdf5.h mega-header? (That's what's recommended at https://support.hdfgroup.org/HDF5/doc/H5.intro.html#Intro-Include). The mega-header seems to just include all the _public.h headers, followed by a few others for I/O stuff.
When it comes to the high-level API, the story seems to be a little different. It also has _public.h headers for the modules, but the mega-header (hdf5_hl.h) seems to pull in hdf5.h before including all the _public.h headers, and the _public.h headers don't seem to do this on their own. So I guess using the mega-header is definitely the recommended way for the high-level API? (would have been nice if the _public.h were directly includable).
Thanks in advance,
Elvis

FWIW, I think I've heard/seen other developers do this too.

That said, have you actually *measured* the impact (in terms of global
symbol reduction) you are able to achieve at compile and/or link time?

You are right in your suspicion, I have not measured :slight_smile: And the gain is
probably negligible. I just started out using the *_public.h because I have
a habit of only including what I strictly need.

The reason I was asking is that I'm now using a tool (
https://include-what-you-use.org/) which analyses my code and makes sure
that I include what I need and nothing more, and I noticed that for HDF5,
I'll have to provide the tool with some mappings to help it on the way, and
that made me think of what is the recommended best practice -- if including
the *_public.h headers is discouraged (if so, I'll make sure the mappings I
feed to the tool suggest the mega-header for all symbols).

Elvis

ยทยทยท

2017-01-27 18:31 GMT+01:00 Miller, Mark C. <miller86@llnl.gov>:

Reason I ask is that its my impression that as HDF5 library is currently
designed and implemented, using any one piece of it can *easily* wind up
bringing in >90% of it.

Now, that is my *impression* only based on very limited examinations of
executables with 'nm' tool and without really *trying* to be sure I am not
doing something stupid.

Mark

"Hdf-forum on behalf of Elvis Stansvik" wrote:

Hi all,

I'm using the C API and I'm currently using e.g.

#include <H5Tpublic.h>

#include <H5Apublic.h>
...

in order to include only what I need and nothing more. (I believe these
headers were called just H5T.h, H5A.h etc in the past BTW).

I'd just like to know if it's supported to be specific like this, or if I
can expect trouble? Should I always include the hdf5.h mega-header? (That's
what's recommended at https://support.hdfgroup.org/
HDF5/doc/H5.intro.html#Intro-Include). The mega-header seems to just
include all the _public.h headers, followed by a few others for I/O stuff.

When it comes to the high-level API, the story seems to be a little
different. It also has _public.h headers for the modules, but the
mega-header (hdf5_hl.h) seems to pull in hdf5.h before including all the
_public.h headers, and the _public.h headers don't seem to do this on their
own. So I guess using the mega-header is definitely the recommended way for
the high-level API? (would have been nice if the _public.h were directly
includable).

Thanks in advance,

Elvis

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5