E3SM icon indicating copy to clipboard operation
E3SM copied to clipboard

EAMxx: to include .h or to include .hpp, that's the design pattern

Open mahf708 opened this issue 9 months ago • 1 comments

In some places in EAMxx, we bare-include a file that will presumably be generated at compile time. An example is eamxx_config.h.in (in components/eamxx/src) --> eamxx_config.h (in the bld folder eventually). In modern IDEs with automatic include-resolution, this will generate a squiggly red line under each include-call recursively. A different pattern is to have an equivalent .hpp file that all other files will include, and which guard-include the generated .h file as conveyed by the snippet below:

#ifndef SCREAM_CONFIG_HPP
#define SCREAM_CONFIG_HPP

#include <string>

// Include this file, not any lower-level configuration file such as that
// generated by CMake from eamxx_config.h.in. The intent is to funnel all
// configuration decisions through this header.

#ifdef SCREAM_CONFIG_IS_CMAKE
# include "eamxx_config.h"
#else
// Purposely error out.
"A non-cmake build of scream is currently not supported."
#endif

The task: explore unifying the pattern across all of EAMxx in the hope of getting modern IDEs to stop showing those annoying squiggly red lines all over the place

CC: @jgfouca @bartgol

mahf708 avatar Apr 08 '25 17:04 mahf708

Note: this will require some code edits in ekat

mahf708 avatar Apr 09 '25 13:04 mahf708