Hello Thomas,
Hello people of bug-ncurses,
These patches now let ncurses build using visual studio and using the ncurses build system.
I've done this in several steps:
- For the gcc-like compiles toolchain, I added an option to enable -fvisibility=hidden.
Hiding symbols by default and only declaring certain symbols public, is the same principle as using __declspec(dllexport)/__declspec(dllimport) for dll's. - I've added a ncurses_exports.h(.in) file that will declare these attributes:
- __declspec(dllexport)/__declspec(dllimport) for windows (msvc and mingw)
- __attribute__((visibility("default"))) for others
- I let each ncurses sublibrary handle its own import/exporting:
- each library gets a preprocessor define (BUILDING_NCURSES/BUILDING_FORM/BUILDING_MENU/...)
- Conditional on the presence of the define above, it will import/export a symbol
- I've improved the autoconf build script support for msvc:
- static libraries need to created as lib -out:name.lib object1.obj object2.obj
Without the -out, is doesn't work
So it creates a mk_static_lib.sh helper script, as is done for shared libraries. - I've modified the file so that the default prefix for msvc builds is the empty string. Libraries built by msvc do not have a lib prefix.
- I've done the same so that the suffix of static libraries is .lib instead of .a.
Apart from the changes to the build system, there were 2 changes rqeuired to ncurses/base/MKlib_gen.sh. When the macro is expanded, too many parentheses are generated and an error is thrown.
> The NOMACROS change will cause the library to not work...
Also, I've (again) defined NCURSES_NOMACROS.
As you wrote as a comment on my pr on github, this is a bug.
But without this change, the following code is created after preprocessing:
spec(dllexport) int __cdecl
waddchnstr(stdscr,(const chtype * z),-1)
{
;
return waddchnstr(stdscr,(z),-1);
}
__declspec(dllexport) int __cdecl
waddnstr(stdscr,(const char * a1),(int z))
{
;
return waddnstr(stdscr,(a1),(z));
}
__declspec(dllexport) int __cdecl
waddnstr(stdscr,(const char * z),-1)
{
;
return waddnstr(stdscr,(z),-1);
}
As you can see, the argument of the functions is not correct.
I hope you can do something with my patches.
Best regards
Maarten