Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of MantidKernel/System.h #38457

Open
peterfpeterson opened this issue Nov 27, 2024 · 3 comments
Open

Get rid of MantidKernel/System.h #38457

peterfpeterson opened this issue Nov 27, 2024 · 3 comments
Labels
Maintenance Unassigned issues to be addressed in the next maintenance period.

Comments

@peterfpeterson
Copy link
Member

peterfpeterson commented Nov 27, 2024

Describe the outcome that is desired.

Remove System.h since it is created in the generate files called DllConfig.h by way of GenerateMantidExporteHeader.cmake

Describe any solutions you are considering

This can be done in stages, but each removal from System.h will invalidate almost the entire build tree. Consider that when planning out the work.

  • Move the #pragma warning(disable: commands from L33, 37, and 42 to exist as compiler flags in WindowsSetup.cmake. When doing the move, consider whether the flags are still necessary.
  • Remove all hand-written DllConfig.h from the source tree and change those sub-packages to use the generated one. At the time of this writing,there are 13.
  • DO SECOND Remove direct #include "MantidKernel/System.h" from everything. Some sub-packages predate the existence of DllConfig.h being created and should use that instead. There are currently 503 files that directly include MantidKernel/System.h.
  • The macros for exporting symbols on L34-55 is generated already by GenerateMantidExportHeader.cmake and can be removed
  • The macros for deprecating symbols on L70-77 is generated already by GenerateMantidExportHeader.cmake and can be removed
  • The macro for UNUSED_ARG on L63-65 is generated already by GenerateMantidExportHeader.cmake and can be removed. Add a comment/link in the generated DllConfig.h that one should consider maybe_unused instead.
  • Remove the includes for cstddef and cstdint. If this generates an excess of changes, move the includes into GENERATE_EXTERN clause of GenerateMantidExportHeader.cmake
  • DO LAST Remove MantidKernel/System.h and update GenerateMantidExportHeader.cmake to not include it.

NOTE ABOUT UNUSED_ARG

This is the main reason why tests include MantidKernel/System.h. Either change them to use the sub-package specific DllConfig.h or change to maybe_unused

@peterfpeterson peterfpeterson added the Maintenance Unassigned issues to be addressed in the next maintenance period. label Nov 27, 2024
@peterfpeterson
Copy link
Member Author

From a small test, removing cstddef from MantidKernel/System.h can be done without much work.

peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 20, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 20, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is for PythonInterface, LiveData, and Nexus subpackages as part
of mantidproject#38457
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is for PythonInterface, LiveData, and Nexus subpackages as part
of mantidproject#38457
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 23, 2024
This is for PythonInterface, LiveData, and Nexus subpackages as part
of mantidproject#38457
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 26, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 27, 2024
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Dec 27, 2024
This is for PythonInterface, LiveData, and Nexus subpackages as part
of mantidproject#38457
@peterfpeterson
Copy link
Member Author

For reference, the generated MantidKernel/DllConfig.h for windows is

#ifndef MANTID_KERNEL_DLL_H
#define MANTID_KERNEL_DLL_H

#ifdef MANTID_KERNEL_STATIC_DEFINE
#  define MANTID_KERNEL_DLL
#  define MANTID_KERNEL_NO_EXPORT
#else
#  ifndef MANTID_KERNEL_DLL
#    ifdef Kernel_EXPORTS
        /* We are building this library */
#      define MANTID_KERNEL_DLL __declspec(dllexport)
#    else
        /* We are using this library */
#      define MANTID_KERNEL_DLL __declspec(dllimport)
#    endif
#  endif

#  ifndef MANTID_KERNEL_NO_EXPORT
#    define MANTID_KERNEL_NO_EXPORT 
#  endif
#endif

#ifndef MANTID_KERNEL_DEPRECATED
#  define MANTID_KERNEL_DEPRECATED __declspec(deprecated)
#endif

#ifndef MANTID_KERNEL_DEPRECATED_EXPORT
#  define MANTID_KERNEL_DEPRECATED_EXPORT MANTID_KERNEL_DLL MANTID_KERNEL_DEPRECATED
#endif

#ifndef MANTID_KERNEL_DEPRECATED_NO_EXPORT
#  define MANTID_KERNEL_DEPRECATED_NO_EXPORT MANTID_KERNEL_NO_EXPORT MANTID_KERNEL_DEPRECATED
#endif

/* NOLINTNEXTLINE(readability-avoid-unconditional-preprocessor-if) */
#if 0 /* DEFINE_NO_DEPRECATED */
#  ifndef MANTID_KERNEL_NO_DEPRECATED
#    define MANTID_KERNEL_NO_DEPRECATED
#  endif
#endif


#ifdef _WIN32
    // 'identifier' : class 'type' needs to have dll-interface to be used by clients
    // of class 'type2'
    // Things from the std library give these warnings and we can't do anything
    // about them.
    #pragma warning(disable : 4251)
    // Given that we are compiling everything with msvc under Windows and
    // linking all with the same runtime we can disable the warning about
    // inheriting from a non-exported interface, e.g. std::runtime_error */
    #pragma warning(disable : 4275)
    // Warning C4373: previous versions of the compiler did not override when
    // parameters only differed by const/volatile qualifiers
    // This is basically saying that it now follows the C++ standard and doesn't
    // seem useful
    #pragma warning(disable : 4373)
#endif

#ifndef UNUSED_ARG
    #define UNUSED_ARG(x) (void) x;
#endif

#ifndef KERNEL_DEPRECATED
    #define KERNEL_DEPRECATED(func) MANTID_KERNEL_DEPRECATED func
#endif

// Use extern keyword in client code to suppress class template instantiation
#include "MantidKernel/System.h"

#ifdef Kernel_EXPORTS
#define EXTERN_MANTID_KERNEL
#else
#define EXTERN_MANTID_KERNEL EXTERN_IMPORT
#endif /* Kernel_EXPORTS*/
 
#endif /* MANTID_KERNEL_DLL_H */

peterfpeterson added a commit to peterfpeterson/mantid that referenced this issue Jan 6, 2025
This is part of mantidproject#38457 which cleans up all of Kernel except the
precompiled headers. System.h is still included in the generated
DllConfig.h file, but all of its necessary functionality should have
been pulled from System.h once everything else is ready.
@martyngigg
Copy link
Member

Just a note.

The Windows #pragma warning in System.h should be able to move to compiler flags in WindowsSetup such as /wd4251. https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170 for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Unassigned issues to be addressed in the next maintenance period.
Projects
None yet
Development

No branches or pull requests

2 participants