Skip to content

Commit

Permalink
Improve omqwt compilation. Fix possbile errors. (#11106)
Browse files Browse the repository at this point in the history
  - Define `QWT_DL` and `QWT_MAKEDLL` accordingly for all Windows compilations
    not just for `MSVC`.

  - Fix const qualifiers in `omc_msvc.c`. Removing const qualifiers on
    return values seems to be considered an error by `MinGW clang-11`.
    Possibly a warning on others.
  • Loading branch information
mahge committed Aug 31, 2023
1 parent c76f46c commit 1c9ed10
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions OMCompiler/SimulationRuntime/c/util/omc_msvc.c
Expand Up @@ -258,7 +258,7 @@ static const char* GetLastErrorAsString()
return str;
}

char* omc_dlerror()
const char* omc_dlerror()
{
return GetLastErrorAsString();
}
Expand All @@ -277,7 +277,7 @@ void* dlopen(const char *filename, int flag) {
return omc_dlopen(filename, flag);
}

char* dlerror() {
const char* dlerror() {
return omc_dlerror();
}

Expand Down
4 changes: 2 additions & 2 deletions OMCompiler/SimulationRuntime/c/util/omc_msvc.h
Expand Up @@ -159,13 +159,13 @@ typedef struct {

char* mkdtemp(char *tpl);
void* omc_dlopen(const char *filename, int flag);
char* omc_dlerror();
const char* omc_dlerror();
void* omc_dlsym(void *handle, const char *symbol);
int omc_dlclose(void *handle);
int omc_dladdr(void *addr, Dl_info *info);

void* dlopen(const char *filename, int flag);
char* dlerror();
const char* dlerror();
void* dlsym(void *handle, const char *symbol);
int dlclose(void *handle);
int dladdr(void *addr, Dl_info *info);
Expand Down
14 changes: 8 additions & 6 deletions OMPlot/qwt/src/CMakeLists.txt
Expand Up @@ -216,12 +216,14 @@ endif ()

add_library(omqwt SHARED ${QWT_HEADERS} ${QWT_SOURCES})

target_compile_definitions(omqwt
PUBLIC
$<$<BOOL:MSVC>:QWT_DLL>
PRIVATE
$<$<BOOL:MSVC>:QWT_MAKEDLL>
)
if(WIN32)
# define QWT_DLL so the headers add the dll export/import specifiers .
target_compile_definitions(omqwt PUBLIC QWT_DLL)
# When compiling omqwt itself, define QWT_MAKEDLL so the headers export the functions.
# Target that link to omqwt will not fet this define (private) which means they will
# dllimport the functions. See src/qwt_global.h:27-35
target_compile_definitions(omqwt PRIVATE QWT_MAKEDLL)
endif()

target_include_directories(omqwt
PUBLIC
Expand Down

0 comments on commit 1c9ed10

Please sign in to comment.