scipopt / scip

SCIP - Solving Constraint Integer Programs
Other
393 stars 63 forks source link

Avoid using -fpermissive flag #36

Closed aabbas-brook closed 1 year ago

aabbas-brook commented 1 year ago

Hi everyone, First of all, thank you for the work and the documentation you have done here, this is great. When trying to compile the simple example (that I putted in a test file) :

#include <scip/scip.h>
#include <string>

TEST(solver, solver_SCIP_SOPLEX_initializarion)
{
    SCIP *scip = NULL;
    SCIP_CALL(SCIPcreate(&scip));                  // initialize SCIP
    SCIPinfoMessage(scip, NULL, "Hello world.\n"); // output greeting
    SCIP_CALL(SCIPfree(&scip));                    // free SCIP
    BMScheckEmptyMemory();
    ASSERT_EQ(1, 1);
}

I am faced to a message error:

In member function ‘virtual void solver_solver_SCIP_SOPLEX_initializarion_Test::TestBody()’:
**[...]**  error: return-statement with a value, in function returning ‘void’ [-fpermissive]

This can be solved by adding in cmake : set(CMAKE_CXX_FLAGS "-fpermissive -std=c++0x"). This point solves the issue but is there a better way to solve this problem?

svigerske commented 1 year ago

SCIP_CALL is a macro that includes a return statement. Use something like SCIP_CALL_ABORT instead.

aabbas-brook commented 1 year ago

Thank you !