Skip to content

Commit

Permalink
Coding - Fixing warning for Clang Open-Cascade-SAS#209
Browse files Browse the repository at this point in the history
Update CMake flags and override methods for improved compatibility
Enhance build configurations and improve code quality with compiler flags
  • Loading branch information
dpasukhi committed Dec 23, 2024
1 parent f7dea47 commit d5f5db1
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 28 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/build-and-test-multiplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ jobs:
-D USE_VTK=ON `
-D USE_TBB=ON `
-D USE_RAPIDJSON=ON `
-D USE_OPENGL=ON ..
-D USE_OPENGL=ON `
-D CMAKE_CXX_FLAGS="/W4 /WX" `
-D CMAKE_C_FLAGS="/W4 /WX" ..
shell: pwsh

- name: Build OCCT
Expand Down Expand Up @@ -141,7 +143,9 @@ jobs:
-D USE_VTK=OFF `
-D USE_TBB=ON `
-D USE_RAPIDJSON=ON `
-D USE_OPENGL=ON ..
-D USE_OPENGL=ON `
-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" `
-D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ..
shell: pwsh

- name: Build OCCT
Expand Down Expand Up @@ -193,7 +197,9 @@ jobs:
-D USE_DRACO=ON \
-D USE_FREETYPE=ON \
-D USE_OPENGL=ON \
-D USE_FREEIMAGE=ON ..
-D USE_FREEIMAGE=ON \
-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \
-D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ..
- name: Build OCCT
run: |
Expand Down Expand Up @@ -244,7 +250,9 @@ jobs:
-D USE_DRACO=ON \
-D USE_FREETYPE=ON \
-D USE_OPENGL=ON \
-D USE_FREEIMAGE=ON ..
-D USE_FREEIMAGE=ON \
-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \
-D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ..
- name: Build OCCT
run: |
Expand Down Expand Up @@ -298,7 +306,9 @@ jobs:
-D USE_VTK=ON \
-D USE_TBB=OFF \
-D USE_RAPIDJSON=ON \
-D USE_OPENGL=ON ..
-D USE_OPENGL=ON \
-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \
-D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ..
- name: Build OCCT
run: |
Expand Down
21 changes: 16 additions & 5 deletions adm/cmake/occt_defs_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ else()
else()
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
endif()
if (APPLE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
endif()
add_definitions(-DOCC_CONVERT_SIGNALS)
endif()

Expand Down Expand Up @@ -152,9 +156,14 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPIL

# Link-Time Code Generation(LTCG) is requared for Whole Program Optimisation(GL)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -flto -Wl,--gc-sections")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -flto -Wl,--gc-sections")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -Wl,--gc-sections")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -flto")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -flto")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto")
if (NOT WIN32)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshorten-64-to-32")
Expand All @@ -173,8 +182,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]")
# CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated.
set (CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
endif()
# Optimize size of binaries
set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
if (NOT WIN32)
# Optimize size of binaries
set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
endif()
endif()
if(MINGW)
add_definitions(-D_WIN32_WINNT=0x0601)
Expand Down
4 changes: 2 additions & 2 deletions src/Aspect/Aspect_OpenVRSession.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1038,13 +1038,13 @@ void Aspect_OpenVRSession::ProcessEvents()
{
case Aspect_XRActionType_InputDigital:
{
Aspect_XRDigitalActionData aData = GetDigitalActionData (anAction);
//Aspect_XRDigitalActionData aData = GetDigitalActionData (anAction);
//if (aData.IsChanged) { std::cout << " " << anAction->Id() << " pressed: " << aData.IsPressed << "\n"; }
break;
}
case Aspect_XRActionType_InputAnalog:
{
Aspect_XRAnalogActionData aData = GetAnalogActionData (anAction);
//Aspect_XRAnalogActionData aData = GetAnalogActionData (anAction);
//if (aData.IsChanged()) { std::cout << " " << anAction->Id() << " changed: " << aData.VecXYZ[0] << " " << aData.VecXYZ[1] << " " << aData.VecXYZ[2] << "\n"; }
break;
}
Expand Down
2 changes: 0 additions & 2 deletions src/ExpToCasExe/exptocas.tab.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ namespace exptocas {
int yylen = 0;

// Error handling.
int yynerrs_ = 0;
int yyerrstatus_ = 0;

/// The lookahead symbol.
Expand Down Expand Up @@ -933,7 +932,6 @@ namespace exptocas {
// If not already recovering from an error, report this error.
if (!yyerrstatus_)
{
++yynerrs_;
std::string msg = YY_("syntax error");
error (YY_MOVE (msg));
}
Expand Down
8 changes: 4 additions & 4 deletions src/IVtkDraw/IVtkDraw_Interactor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public:

vtkTypeMacro (IVtkDraw_Interactor, vtkRenderWindowInteractor)

virtual void Initialize();
virtual void Enable();
virtual void Start() { }
virtual void Initialize() Standard_OVERRIDE;
virtual void Enable() Standard_OVERRIDE;
virtual void Start() Standard_OVERRIDE { }

const PSelector& Selector() const { return mySelector; }
void SetShapePicker (const PSelector& theSelector);
Expand Down Expand Up @@ -97,7 +97,7 @@ protected:
void OnMouseWheelBackward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
#else
static void ProcessEvents (ClientData theData, int);
void GetMousePosition (Standard_Integer *theX, Standard_Integer *theY);
void GetMousePosition (Standard_Integer *theX, Standard_Integer *theY) Standard_OVERRIDE;
#endif

private:
Expand Down
2 changes: 1 addition & 1 deletion src/IVtkTools/IVtkTools_DisplayModeFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public:
vtkTypeMacro(IVtkTools_DisplayModeFilter,IVtkTools_SubPolyDataFilter)

static IVtkTools_DisplayModeFilter *New();
void PrintSelf (std::ostream& os, vtkIndent indent);
void PrintSelf (std::ostream& os, vtkIndent indent) Standard_OVERRIDE;

//! Set display mode to define cells types to be passed through this filter.
void SetDisplayMode (const IVtk_DisplayMode aMode);
Expand Down
2 changes: 1 addition & 1 deletion src/IVtkTools/IVtkTools_SubPolyDataFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public:
vtkTypeMacro(IVtkTools_SubPolyDataFilter,vtkPolyDataAlgorithm)

static IVtkTools_SubPolyDataFilter *New();
void PrintSelf (std::ostream& theOs, vtkIndent theIndent);
void PrintSelf (std::ostream& theOs, vtkIndent theIndent) Standard_OVERRIDE;

//! Set ids to be passed through this filter.
void SetData(const IVtk_IdTypeMap theSet);
Expand Down
4 changes: 3 additions & 1 deletion src/ShapeProcess/ShapeProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ Standard_Boolean ShapeProcess::Perform(const Handle(ShapeProcess_Context)& theCo
std::vector<std::pair<const char*, Handle(ShapeProcess_Operator)>> ShapeProcess::getOperators(const OperationsFlags& theFlags)
{
std::vector<std::pair<const char*, Handle(ShapeProcess_Operator)>> aResult;
for (std::underlying_type<Operation>::type anOperation = Operation::First; anOperation < Operation::Count; ++anOperation)
for (std::underlying_type<Operation>::type anOperation = static_cast<std::underlying_type<Operation>::type>(Operation::First);
anOperation <= static_cast<std::underlying_type<Operation>::type>(Operation::Last);
++anOperation)
{
if (theFlags.test(anOperation))
{
Expand Down
7 changes: 3 additions & 4 deletions src/ShapeProcess/ShapeProcess.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public:
DEFINE_STANDARD_ALLOC

//! Describes all available operations.
//! C++11 enum class is not used to allow implicit conversion to undelying type.
enum Operation : uint8_t
enum class Operation : uint8_t
{
First = 0, // First operation index.
DirectFaces = First,
Expand All @@ -61,7 +60,7 @@ public:
FixShape,
SplitClosedEdges,
SplitCommonVertex,
Count // Number of operations.
Last = SplitCommonVertex // Last operation index.
};

// Bitset of operations. It is used to specify which operations should be performed.
Expand All @@ -70,7 +69,7 @@ public:
// flags.set(ShapeProcess::Operation::DirectFaces);
// flags.set(ShapeProcess::Operation::SameParameter);
// ShapeProcess::Perform(context, flags);
using OperationsFlags = std::bitset<Operation::Count>;
using OperationsFlags = std::bitset<static_cast<uint8_t>(Operation::Last) + 1>;

public:
//! Registers operator to make it visible for Performer
Expand Down
2 changes: 1 addition & 1 deletion src/StepFile/lex.step.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ int yyFlexLexer::LexerInput( char* buf, int max_size )
if ( yyin.bad() )
return -1;
else
return yyin.gcount();
return static_cast<int>(yyin.gcount());
#endif
}

Expand Down
2 changes: 0 additions & 2 deletions src/StepFile/step.tab.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ namespace step {
int yylen = 0;

// Error handling.
int yynerrs_ = 0;
int yyerrstatus_ = 0;

/// The lookahead symbol.
Expand Down Expand Up @@ -681,7 +680,6 @@ namespace step {
// If not already recovering from an error, report this error.
if (!yyerrstatus_)
{
++yynerrs_;
context yyctx (*this, yyla);
std::string msg = yysyntax_error_ (yyctx);
error (YY_MOVE (msg));
Expand Down

0 comments on commit d5f5db1

Please sign in to comment.