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

Fix #8312 - EnergyPlus Build Warnings on gcc >= 9 #8391

Merged
merged 15 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ ELSEIF ( CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
ADD_CXX_DEFINITIONS("-pipe") # Faster compiler processing
ADD_CXX_DEFINITIONS("-pedantic") # Turn on warnings about constructs/situations that may be non-portable or outside of the standard
ADD_CXX_DEFINITIONS("-Wall -Wextra") # Turn on warnings
ADD_CXX_DEFINITIONS("-Werror") # Treat warnings as errors
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious to see if clang will throw or not. We can remove this line if it's problematic, but it worked on GCC and we might as well turn it on to avoid having warnings sneak into the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@jmarrec jmarrec Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Enabling /W4 or /Wall on windows would be interesting too)

STRING (REGEX REPLACE "/W3" "/W1" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Increase to /W2 then /W3 as more serious warnings are addressed (using regex to avoid VC override warnings)

ADD_CXX_DEFINITIONS("-Wno-unknown-pragmas")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
ADD_CXX_DEFINITIONS("-Wno-deprecated-copy")
Expand Down
3 changes: 3 additions & 0 deletions src/EnergyPlus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ if(BUILD_GROUND_PLOT)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries( energypluslib dl )
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
target_link_libraries( energypluslib util )
endif()
Comment on lines +797 to +799
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't link without this on GCC 10. Undefined reference to forkpty and openpty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endif()
if (WIN32)
target_link_libraries( energypluslib Shlwapi )
Expand Down
2 changes: 1 addition & 1 deletion third_party/FMI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SET(SRC
ADD_LIBRARY( epfmiimport STATIC ${SRC} )

IF (UNIX)
ADD_DEFINITIONS("-fPIC")
ADD_DEFINITIONS("-fPIC -Wall -Wno-maybe-uninitialized -Wno-switch -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Werror")
ENDIF()

TARGET_LINK_LIBRARIES( epfmiimport epexpat miniziplib )
Expand Down
65 changes: 32 additions & 33 deletions third_party/FMI/eplusModelFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@
///
///
/// \author Thierry Stephane Nouidui,
/// Simulation Research Group,
/// Simulation Research Group,
/// LBNL,
/// [email protected]
///
/// \date 2011-11-11
///
/// This header file defines the energyplus functions
/// This header file defines the energyplus functions
/// that mapped to fmiFunctions and will be exported
/// in .dll
///////////////////////////////////////////////////////

#include "FMI/fmiModelFunctions.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include problem.

#include "fmiModelTypes.h"
#include <stdlib.h>
/* Export fmi functions on Windows */
#ifdef _MSC_VER
#define DllExport __declspec( dllexport )
#define DllImport __declspec( dllexport )
#define DllExport __declspec(dllexport)
#define DllImport __declspec(dllexport)

#else
#define DllExport
#endif

/* make sure all compiler use the same alignment policies for structures */
#ifdef WIN32
#pragma pack(push,8)
#pragma pack(push, 8)
#endif

/* Version number */
Expand All @@ -46,48 +47,46 @@
EnergyPlus Functions for FMI for Co-Simulation

****************************************************/
DllExport fmiComponent fmiEPlusInstantiateSlave(char* fmuResFolder,
fmiInteger *sizefmuResFolder, fmiReal *timeOut, fmiInteger *visible,
fmiInteger *interactive, fmiInteger *loggingOn, fmiInteger *index);
DllExport fmiComponent fmiEPlusInstantiateSlave(char *fmuResFolder,
fmiInteger *sizefmuResFolder,
fmiReal *timeOut,
fmiInteger *visible,
fmiInteger *interactive,
fmiInteger *loggingOn,
fmiInteger *index);
Comment on lines +51 to +56
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plenty of changes are due to the fact that I clang-formatted all the files in the FMI and FMUParser folders, as they were pretty messy.


DllExport fmiStatus fmiEPlusInitializeSlave(fmiComponent *fmuInstance,
fmiReal *tStart, fmiInteger *newStep, fmiReal *tStop, fmiInteger *index);
DllExport fmiStatus fmiEPlusInitializeSlave(fmiComponent *fmuInstance, fmiReal *tStart, fmiInteger *newStep, fmiReal *tStop, fmiInteger *index);

DllExport fmiStatus fmiEPlusGetReal(fmiComponent *fmuInstance, const fmiValueReference valRef [],
fmiReal outValue[], fmiInteger *numOutputs, fmiInteger *index);
DllExport fmiStatus
fmiEPlusGetReal(fmiComponent *fmuInstance, const fmiValueReference valRef[], fmiReal outValue[], fmiInteger *numOutputs, fmiInteger *index);

DllExport fmiStatus fmiEPlusSetReal(fmiComponent *fmuInstance, const fmiValueReference valRef[],
fmiReal inpVal[], fmiInteger *numInputs, fmiInteger *index);
DllExport fmiStatus
fmiEPlusSetReal(fmiComponent *fmuInstance, const fmiValueReference valRef[], fmiReal inpVal[], fmiInteger *numInputs, fmiInteger *index);

DllExport fmiStatus fmiEPlusDoStep(fmiComponent *fmuInstance, fmiReal *curCommPoint,
fmiReal *commStepSize, fmiInteger *newStep, fmiInteger *index);
DllExport fmiStatus fmiEPlusDoStep(fmiComponent *fmuInstance, fmiReal *curCommPoint, fmiReal *commStepSize, fmiInteger *newStep, fmiInteger *index);

DllExport fmiStatus fmiEPlusFreeSlave(fmiComponent *fmuInstance, fmiInteger *index, fmiInteger *fmiEndSimulation);

fmiStatus fmiEPlusResetSlave(fmiComponent *fmuInstance, fmiInteger *index);
fmiStatus fmiEPlusResetSlave(fmiComponent *fmuInstance, fmiInteger *index);

DllExport fmiInteger fmiEPlusUnpack(char* fmuName, char* fmuOutputWorkingFolder,
fmiInteger *sizefmuName, fmiInteger *sizefmuOutputWorkingFolder);
DllExport fmiInteger fmiEPlusUnpack(char *fmuName, char *fmuOutputWorkingFolder, fmiInteger *sizefmuName, fmiInteger *sizefmuOutputWorkingFolder);

DllExport fmiInteger addLibPathCurrentWorkingFolder(char* trimfmuOutputWorkingFolder_wLiB,
char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, fmiInteger *index);
DllExport fmiInteger addLibPathCurrentWorkingFolder(char *trimfmuOutputWorkingFolder_wLiB,
char *fmuWorkingFolder,
fmiInteger *sizefmuWorkingFolder,
fmiInteger *index);

DllExport fmiValueReference getValueReferenceByNameFMUInputVariables(char* variableName,
fmiInteger *sizeVariableName, fmiInteger *index);
DllExport fmiValueReference getValueReferenceByNameFMUInputVariables(char *variableName, fmiInteger *sizeVariableName, fmiInteger *index);

DllExport fmiValueReference getValueReferenceByNameFMUOutputVariables(char* variableName,
fmiInteger *sizeVariableName, fmiInteger *index);
DllExport fmiValueReference getValueReferenceByNameFMUOutputVariables(char *variableName, fmiInteger *sizeVariableName, fmiInteger *index);

DllExport fmiInteger model_ID_GUID(char* fmuInstanceName, char* fmuWorkingFolder,
fmiInteger *sizefmuWorkingFolder, fmiInteger *numInputs,
fmiInteger *numOutputs);
DllExport fmiInteger
model_ID_GUID(char *fmuInstanceName, char *fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, fmiInteger *numInputs, fmiInteger *numOutputs);

DllExport fmiInteger addFMURootFolderName(char* fmuOutputWorkingFolder,
char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder);
DllExport fmiInteger addFMURootFolderName(char *fmuOutputWorkingFolder, char *fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder);

DllExport fmiInteger getfmiEPlusVersion(char* fmuWorkingFolder,
fmiInteger *sizefmuWorkingFolder, char *fmiVersionNumber, fmiInteger *index);
DllExport fmiInteger getfmiEPlusVersion(char *fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, char *fmiVersionNumber, fmiInteger *index);

DllExport fmiInteger checkOperatingSystem(char* errorMessage);
DllExport fmiInteger checkOperatingSystem(char *errorMessage);

#endif // eplusModelFunctions_h
Loading