Merge "[567611] Code generator produces invalid code for FBs with 0 event ins or outs" into develop
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ff6f14..11c8f02 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,15 +1,17 @@
- #*******************************************************************************
-# Copyright (c) 2010 - 2015 ACIN, Profactor GmbH, AIT, fortiss GmbH
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License 2.0 which is available at
-# http://www.eclipse.org/legal/epl-2.0.
-#
+#********************************************************************************
+# Copyright (c) 2010 - 2015 Profactor GmbH, AIT, fortiss GmbH
+# 2010-2015, 2020 TU Wien/ACIN
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License 2.0 which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
# SPDX-License-Identifier: EPL-2.0
-#
-# Contributors:
+#
+# Contributors:
# Michael Hofmann, Alois Zoitl, Gerhard Ebenhofer, Ingo Hegny, Thomas Strasser,
-# * Martin Melik Merkumians
-# * - initial API and implementation and/or initial documentation
+# Martin Melik Merkumians
+# - initial API and implementation and/or initial documentation
+# Martin Melik Merkumians - adds compiler feature check for nullptr
# *******************************************************************************/
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
@@ -30,6 +32,10 @@
#include forte cmake-functions
INCLUDE(${FORTE_BUILDSUPPORT_DIRECTORY}/forte.cmake)
+INCLUDE(${FORTE_BUILDSUPPORT_DIRECTORY}/check_compiler_features.cmake)
+
+TEST_NEEDED_FORTE_COMPILER_FEATURES() #Checl for compiler features and either apply fixes or error messages if not supported
+
forte_add_definition("-DFORTE_COMPILATION") #Allow to tell external modules/middleware that forte is being compiled, so special defines can be added
diff --git a/buildsupport/check_compiler_features.cmake b/buildsupport/check_compiler_features.cmake
new file mode 100644
index 0000000..bd166c7
--- /dev/null
+++ b/buildsupport/check_compiler_features.cmake
@@ -0,0 +1,23 @@
+#********************************************************************************
+# Copyright (c) 2020 TU Wien/ACIN
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License 2.0 which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# SPDX-License-Identifier: EPL-2.0
+#
+# Contributors:
+# Martin Melik Merkumians
+# - initial API and implementation and/or initial documentation
+# *******************************************************************************/
+include(CheckCXXSourceCompiles)
+
+MACRO(TEST_NEEDED_FORTE_COMPILER_FEATURES)
+CHECK_CXX_SOURCE_COMPILES("int main() { void* p = nullptr; }"
+ NULLPTR_SUPPORTED
+ FAIL_REGEX "use of undeclared identifier 'nullptr'")
+if(NOT NULLPTR_SUPPORTED)
+ message(WARNING "`nullptr` not supported, replacing it with 0 via precprocessor")
+ forte_add_definition("-Dnullptr=0")
+endif()
+ENDMACRO(TEST_NEEDED_FORTE_COMPILER_FEATURES)
\ No newline at end of file
diff --git a/src/arch/datatype.h b/src/arch/datatype.h
index c126b95..ea7a24c 100644
--- a/src/arch/datatype.h
+++ b/src/arch/datatype.h
@@ -14,7 +14,6 @@
#ifndef _DATATYPES_H_
#define _DATATYPES_H_
-
// this define is required to get the limit macros
#define __STDC_LIMIT_MACROS
diff --git a/src/modules/utils/E_STOPWATCH.cpp b/src/modules/utils/E_STOPWATCH.cpp
index 646a5f5..10a110a 100644
--- a/src/modules/utils/E_STOPWATCH.cpp
+++ b/src/modules/utils/E_STOPWATCH.cpp
@@ -27,7 +27,6 @@
const CStringDictionary::TStringId FORTE_E_STOPWATCH::scm_anDataOutputTypeIds[] = {g_nStringIdTIME};
-const TDataIOID FORTE_E_STOPWATCH::scm_anEIWith[] = {};
const TForteInt16 FORTE_E_STOPWATCH::scm_anEIWithIndexes[] = {-1, -1};
const CStringDictionary::TStringId FORTE_E_STOPWATCH::scm_anEventInputNames[] = {g_nStringIdSTART, g_nStringIdSTOP};
@@ -37,26 +36,23 @@
const SFBInterfaceSpec FORTE_E_STOPWATCH::scm_stFBInterfaceSpec = {
- 2, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes,
+ 2, scm_anEventInputNames, nullptr, scm_anEIWithIndexes,
1, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes,
- 0, 0, 0,
+ 0, nullptr, nullptr,
1, scm_anDataOutputNames, scm_anDataOutputTypeIds,
- 0, 0
+ 0, nullptr
};
const CStringDictionary::TStringId FORTE_E_STOPWATCH::scm_anInternalsNames[] = {g_nStringIdstartTime};
const CStringDictionary::TStringId FORTE_E_STOPWATCH::scm_anInternalsTypeIds[] = {g_nStringIdTIME};
-
const SInternalVarsInformation FORTE_E_STOPWATCH::scm_stInternalVars = {1, scm_anInternalsNames, scm_anInternalsTypeIds};
-
-
void FORTE_E_STOPWATCH::alg_captureStartTime(void) {
st_startTime() = NOW_MONOTONIC();
}
void FORTE_E_STOPWATCH::alg_calcDiff(void) {
- st_TD() = (NOW_MONOTONIC() - st_startTime());
+ st_TD() = SUB(NOW_MONOTONIC(), st_startTime());
}
diff --git a/src/modules/utils/E_STOPWATCH.h b/src/modules/utils/E_STOPWATCH.h
index b443e15..6289811 100644
--- a/src/modules/utils/E_STOPWATCH.h
+++ b/src/modules/utils/E_STOPWATCH.h
@@ -33,22 +33,21 @@
static const TEventID scm_nEventSTARTID = 0;
static const TEventID scm_nEventSTOPID = 1;
- static const TDataIOID scm_anEIWith[];
static const TForteInt16 scm_anEIWithIndexes[];
static const CStringDictionary::TStringId scm_anEventInputNames[];
static const TEventID scm_nEventEOID = 0;
- static const TDataIOID scm_anEOWith[];
+ static const TDataIOID scm_anEOWith[];
static const TForteInt16 scm_anEOWithIndexes[];
static const CStringDictionary::TStringId scm_anEventOutputNames[];
static const SFBInterfaceSpec scm_stFBInterfaceSpec;
-
- static const CStringDictionary::TStringId scm_anInternalsNames[];
- static const CStringDictionary::TStringId scm_anInternalsTypeIds[];
- static const SInternalVarsInformation scm_stInternalVars;
+
+static const CStringDictionary::TStringId scm_anInternalsNames[];
+static const CStringDictionary::TStringId scm_anInternalsTypeIds[];
+static const SInternalVarsInformation scm_stInternalVars;
CIEC_TIME &st_TD() {
return *static_cast<CIEC_TIME*>(getDO(0));
@@ -79,7 +78,7 @@
CBasicFB(pa_poSrcRes, &scm_stFBInterfaceSpec, pa_nInstanceNameId, &scm_stInternalVars, m_anFBConnData, m_anFBVarsData) {
};
- virtual ~FORTE_E_STOPWATCH(){};
+ virtual ~FORTE_E_STOPWATCH() = default;
};
#endif // _E_STOPWATCH_H_