ros / rosconsole

17 stars 61 forks source link

dll import/export visibility macro update #26

Closed kejxu closed 5 years ago

kejxu commented 5 years ago

further updates to support DLL import/export on Windows =)

as mentioned in the comments, the ROSCONSOLE_CONSOLE_IMPL_DECL macro is added to manage visibility for functions in the impl components in one centralized position. For the implementations (src/rosconsole/impl/rosconsole_xxx.cpp), ROSCONSOLE_CONSOLE_IMPL_EXPORTS needs to be defined in the .cpp file before including console_impl.h since these files are compiled to generate their own runtime binaries (dlls). Another way of achieving the same result would be to use independent visibility control macros for each implementation; however, that means more duplicated code and makes it harder to manage.

Another reason to use a centralized header is so that it'd be easier to notice when the declaration and definition have a mismatch (at compile time); otherwise, such mismatch would cause error at runtime, making it harder to spot.

dirk-thomas commented 5 years ago

Thanks for the patch.