diff --git a/.CI/Jenkinsfile b/.CI/Jenkinsfile index 4018c1f6ee..ca8170359e 100644 --- a/.CI/Jenkinsfile +++ b/.CI/Jenkinsfile @@ -197,14 +197,14 @@ def allAutotools() { def autotools(CC, CPPFLAGS, config, nostatic, dotest) { sh label: "Build $CC $CPPFLAGS", script: """ export CC=$CC - export CPPFLAGS="$CPPFLAGS -I${WORKSPACE}/.CI/Test" + export CPPFLAGS=$CPPFLAGS export CFLAGS="-Os -fPIC" rm -rf Modelica/Resources/Library/* mkdir -p Modelica/Resources/Library/\$LIBDIR cd Modelica/Resources/BuildProjects/autotools git clean -fdx . ./autogen.sh - ./configure --libdir="${WORKSPACE}/Modelica/Resources/Library/\$LIBDIR" $config + ./configure --libdir="\$PWD/../../Library/\$LIBDIR" $config make --output-sync -j${numPhysicalCPU()} make install """ @@ -223,7 +223,7 @@ def makefile(CC, dotest) { rm -rf Modelica/Resources/Library/* mkdir -p "Modelica/Resources/Library/$LIBDIR" cd Modelica/Resources/BuildProjects/gcc - make --output-sync -j${numPhysicalCPU()} TARGETDIR="$LIBDIR" CPPFLAGS="-I${WORKSPACE}/.CI/Test" + make --output-sync -j${numPhysicalCPU()} TARGETDIR="$LIBDIR" """ sh label: "Test $CC", script: """ export CC=$CC diff --git a/.CI/Test/Common.c b/.CI/Test/Common.c index e49d23ae7b..43c95769a3 100644 --- a/.CI/Test/Common.c +++ b/.CI/Test/Common.c @@ -1,4 +1,4 @@ -#include "ModelicaUtilities.h" +#include "../../Modelica/Resources/C-Sources/ModelicaUtilities.h" #include #include #include diff --git a/.github/workflows/checkCI.yml b/.github/workflows/checkCI.yml index a6a82f2f61..b32093310d 100644 --- a/.github/workflows/checkCI.yml +++ b/.github/workflows/checkCI.yml @@ -25,7 +25,7 @@ jobs: pushd Modelica/Resources/BuildProjects/autotools git clean -fdx . ./autogen.sh - ./configure --libdir="$PWD/../../Library/$LIBDIR" --enable-static --disable-shared --enable-static-zlib --disable-hdf5 CPPFLAGS="-I${GITHUB_WORKSPACE}/.CI/Test" + ./configure --libdir="$PWD/../../Library/$LIBDIR" --enable-static --disable-shared --enable-static-zlib --disable-hdf5 popd env: LIBDIR: linux64 @@ -79,15 +79,14 @@ jobs: - name: Configure run: | if [ "${{ matrix.compiler }}" == "msvc" ]; then - cmake -S "$SRCDIR" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$TESTDIR" -DMODELICA_DEBUG_TIME_EVENTS=ON + cmake -S "$SRCDIR" -B build -DMODELICA_DEBUG_TIME_EVENTS=ON elif [ "${{ matrix.compiler }}" == "mingw" ]; then - cmake -S "$SRCDIR" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$TESTDIR" -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -G "MinGW Makefiles" + cmake -S "$SRCDIR" -B build -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -G "MinGW Makefiles" else - cmake -S "$SRCDIR" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$TESTDIR" -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_C_FLAGS="-std=c89 -Wall -Wextra" + cmake -S "$SRCDIR" -B build -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_C_FLAGS="-std=c89 -Wall -Wextra" fi env: SRCDIR: ${{ github.workspace }}/Modelica/Resources - TESTDIR: ${{ github.workspace }}/.CI/Test - name: Build with ${{ matrix.compiler }} run: | if [ "${{ matrix.compiler }}" == "msvc" ]; then @@ -120,12 +119,11 @@ jobs: - name: Configure run: | export PATH=/usr/bin:$PATH - cmake -S "$(cygpath ${SRCDIR})" -B build -DMODELICA_UTILITIES_INCLUDE_DIR="$(cygpath ${TESTDIR})" -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=Debug -G Ninja + cmake -S "$(cygpath ${SRCDIR})" -B build -DMODELICA_DEBUG_TIME_EVENTS=ON -DCMAKE_BUILD_TYPE=Debug -G Ninja shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}' env: CYGWIN_NOWINPATH: 1 SRCDIR: ${{ github.workspace }}/Modelica/Resources - TESTDIR: ${{ github.workspace }}/.CI/Test - name: Build with gcc run: | export PATH=/usr/bin:$PATH diff --git a/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaIO.vcproj b/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaIO.vcproj index 2cd3e4eedb..b6e0a79592 100644 --- a/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaIO.vcproj +++ b/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaIO.vcproj @@ -43,7 +43,7 @@ + + @@ -297,6 +301,4 @@ > - - diff --git a/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaMatIO.vcproj b/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaMatIO.vcproj index 8c02967f5a..0e08ee6da4 100644 --- a/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaMatIO.vcproj +++ b/Modelica/Resources/BuildProjects/VisualStudio2005/ModelicaMatIO.vcproj @@ -43,7 +43,7 @@ + + + + = 201112L -#define MODELICA_NORETURN _Noreturn -#define MODELICA_NORETURNATTR -#elif defined(__cplusplus) && __cplusplus >= 201103L -#if (defined(__GNUC__) && __GNUC__ >= 5) || \ - (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 8) -#define MODELICA_NORETURN [[noreturn]] -#define MODELICA_NORETURNATTR -#elif (defined(__GNUC__) && __GNUC__ >= 3) || \ - (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 2 && __GNUC_MINOR__ >= 8) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR __attribute__((noreturn)) -#elif defined(__GNUC__) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR -#else +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L && \ + (!defined(__GNUC__) || __GNUC__ >= 5 || (__GNUC__ == 4 && defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 8))) #define MODELICA_NORETURN [[noreturn]] -#define MODELICA_NORETURNATTR -#endif -#elif defined(__clang__) -/* Encapsulated for Clang since GCC fails to process __has_attribute */ -#if __has_attribute(noreturn) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR __attribute__((noreturn)) -#else -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR -#endif -#elif (defined(__GNUC__) && __GNUC__ >= 3) || \ - (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 2 && __GNUC_MINOR__ >= 8) || \ - (defined(__SUNPRO_C) && __SUNPRO_C >= 0x5110) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR __attribute__((noreturn)) -#elif (defined(_MSC_VER) && _MSC_VER >= 1200) || \ - defined(__BORLANDC__) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define MODELICA_NORETURN _Noreturn +#elif (defined(_MSC_VER) && _MSC_VER >= 1200) || defined(__BORLANDC__) #define MODELICA_NORETURN __declspec(noreturn) -#define MODELICA_NORETURNATTR #else #define MODELICA_NORETURN -#define MODELICA_NORETURNATTR #endif -MODELICA_NORETURN static void ModelicaNotExistError(const char* name) MODELICA_NORETURNATTR; +MODELICA_NORETURN static void ModelicaNotExistError(const char* name); static void ModelicaNotExistError(const char* name) { /* Print error message if a function is not implemented */ ModelicaFormatError("C-Function \"%s\" is called " @@ -159,7 +127,6 @@ static void ModelicaNotExistError(const char* name) { } #undef MODELICA_NORETURN -#undef MODELICA_NORETURNATTR void ModelicaIO_readMatrixSizes(_In_z_ const char* fileName, _In_z_ const char* matrixName, _Out_ int* dim) { diff --git a/.CI/Test/ModelicaUtilities.h b/Modelica/Resources/C-Sources/ModelicaUtilities.h similarity index 77% rename from .CI/Test/ModelicaUtilities.h rename to Modelica/Resources/C-Sources/ModelicaUtilities.h index 1dfa97cf56..e966529adf 100644 --- a/.CI/Test/ModelicaUtilities.h +++ b/Modelica/Resources/C-Sources/ModelicaUtilities.h @@ -1,6 +1,6 @@ /* ModelicaUtilities.h - External utility functions header - Copyright (C) 2010-2024, Modelica Association and contributors + Copyright (C) 2010-2025, Modelica Association and contributors All rights reserved. Redistribution and use in source and binary forms, with or without @@ -53,52 +53,20 @@ extern "C" { external Modelica C-code in most compilers, noreturn attributes need to be present to avoid warnings or errors. - The following macros handle noreturn attributes according to the - C11/C++11 standard with fallback to GNU, Clang or MSVC extensions if using - an older compiler. + The following macro handles the noreturn attribute according to the + C23/C11/C++11 standard with fallback to the MSVC/Borland extension. */ #undef MODELICA_NORETURN -#undef MODELICA_NORETURNATTR -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -#define MODELICA_NORETURN _Noreturn -#define MODELICA_NORETURNATTR -#elif defined(__cplusplus) && __cplusplus >= 201103L -#if (defined(__GNUC__) && __GNUC__ >= 5) || \ - (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 8) +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L && \ + (!defined(__GNUC__) || __GNUC__ >= 5 || (__GNUC__ == 4 && defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 8))) #define MODELICA_NORETURN [[noreturn]] -#define MODELICA_NORETURNATTR -#elif (defined(__GNUC__) && __GNUC__ >= 3) || \ - (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 2 && __GNUC_MINOR__ >= 8) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR __attribute__((noreturn)) -#elif defined(__GNUC__) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR -#else -#define MODELICA_NORETURN [[noreturn]] -#define MODELICA_NORETURNATTR -#endif -#elif defined(__clang__) -/* Encapsulated for Clang since GCC fails to process __has_attribute */ -#if __has_attribute(noreturn) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR __attribute__((noreturn)) -#else -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR -#endif -#elif (defined(__GNUC__) && __GNUC__ >= 3) || \ - (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 2 && __GNUC_MINOR__ >= 8) || \ - (defined(__SUNPRO_C) && __SUNPRO_C >= 0x5110) -#define MODELICA_NORETURN -#define MODELICA_NORETURNATTR __attribute__((noreturn)) -#elif (defined(_MSC_VER) && _MSC_VER >= 1200) || \ - defined(__BORLANDC__) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define MODELICA_NORETURN _Noreturn +#elif (defined(_MSC_VER) && _MSC_VER >= 1200) || defined(__BORLANDC__) #define MODELICA_NORETURN __declspec(noreturn) -#define MODELICA_NORETURNATTR #else #define MODELICA_NORETURN -#define MODELICA_NORETURNATTR #endif /* @@ -138,7 +106,7 @@ void ModelicaVFormatMessage(const char *format, va_list args) MODELICA_FORMATATT Output the message under the same format control as the C-function vprintf. */ -MODELICA_NORETURN void ModelicaError(const char *string) MODELICA_NORETURNATTR; +MODELICA_NORETURN void ModelicaError(const char *string); /* Output the error message string (no format control). This function never returns to the calling function, but handles the error @@ -160,14 +128,14 @@ void ModelicaVFormatWarning(const char *format, va_list args) MODELICA_FORMATATT Output the warning message under the same format control as the C-function vprintf. */ -MODELICA_NORETURN void ModelicaFormatError(const char *format, ...) MODELICA_NORETURNATTR MODELICA_FORMATATTR_PRINTF; +MODELICA_NORETURN void ModelicaFormatError(const char *format, ...) MODELICA_FORMATATTR_PRINTF; /* Output the error message under the same format control as the C-function printf. This function never returns to the calling function, but handles the error similarly to an assert in the Modelica code. */ -MODELICA_NORETURN void ModelicaVFormatError(const char *format, va_list args) MODELICA_NORETURNATTR MODELICA_FORMATATTR_VPRINTF; +MODELICA_NORETURN void ModelicaVFormatError(const char *format, va_list args) MODELICA_FORMATATTR_VPRINTF; /* Output the error message under the same format control as the C-function vprintf. This function never returns to the calling function, @@ -211,7 +179,6 @@ the error. */ #undef MODELICA_NORETURN -#undef MODELICA_NORETURNATTR #undef MODELICA_FORMATATTR_PRINTF #undef MODELICA_FORMATATTR_VPRINTF diff --git a/Modelica/Resources/CMakeLists.txt b/Modelica/Resources/CMakeLists.txt index f3a3f37fac..416978989e 100644 --- a/Modelica/Resources/CMakeLists.txt +++ b/Modelica/Resources/CMakeLists.txt @@ -11,10 +11,12 @@ project(Modelica_Standard_Library_Tables C) set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set(MODELICA_RESOURCES_DIR "${PROJECT_SOURCE_DIR}") +set(MODELICA_UTILITIES_INCLUDE_DIR "${MODELICA_RESOURCES_DIR}/C-Sources") + include(BuildProjects/CMake/Modelica_platform.cmake) include(BuildProjects/CMake/Modelica_utilities.cmake) -set(MODELICA_RESOURCES_DIR "${PROJECT_SOURCE_DIR}") set( CMAKE_INSTALL_PREFIX "${MODELICA_RESOURCES_DIR}" CACHE PATH diff --git a/Modelica/Resources/Licenses/LICENSE_ModelicaIO.txt b/Modelica/Resources/Licenses/LICENSE_ModelicaIO.txt index 6e36b4ec4b..22bf763e82 100644 --- a/Modelica/Resources/Licenses/LICENSE_ModelicaIO.txt +++ b/Modelica/Resources/Licenses/LICENSE_ModelicaIO.txt @@ -1,4 +1,4 @@ -Copyright (C) 2016-2024, Modelica Association and contributors +Copyright (C) 2016-2025, Modelica Association and contributors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Modelica/Resources/Licenses/LICENSE_ModelicaUtilities.txt b/Modelica/Resources/Licenses/LICENSE_ModelicaUtilities.txt new file mode 100644 index 0000000000..be178f137e --- /dev/null +++ b/Modelica/Resources/Licenses/LICENSE_ModelicaUtilities.txt @@ -0,0 +1,27 @@ +Copyright (C) 2010-2025, Modelica Association and contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Modelica/Utilities/Streams.mo b/Modelica/Utilities/Streams.mo index ceed866f44..b19600e407 100644 --- a/Modelica/Utilities/Streams.mo +++ b/Modelica/Utilities/Streams.mo @@ -120,7 +120,7 @@ separated by LF or CR-LF. pure function error "Print error message and cancel all actions - in case of an unrecoverable error" extends Modelica.Icons.Function; input String string "String to be printed to error message window"; - external "C" ModelicaError(string) annotation(Include="#include \"ModelicaUtilities.h\"", Library="ModelicaExternalC"); + external "C" ModelicaError(string) annotation(IncludeDirectory="modelica://Modelica/Resources/C-Sources", Include="#include \"ModelicaUtilities.h\"", Library="ModelicaExternalC"); annotation (Documentation(info="

Syntax