I'm building Lexilla 5.2.9 with Visual Studio 2022 on Windows 11.
I link my C++ application with the static library liblexilla.lib.
I wrote a custom lexer, and I expected to be able to register it with AddStaticLexerModule(). However, I get a link error stating that it can't link this function:
1>CustomLexer.obj : error LNK2019: unresolved external symbol "void cdecl AddStaticLexerModule(class Lexilla::LexerModule )" (?AddStaticLexerModule@@YAXPEAVLexerModule@Lexilla@@@Z) referenced in function "public: static void cdecl CustomLexer::Initialise(void)" (?Initialise@CustomLexer@@SAXXZ)
1> Hint on symbols that are defined and could potentially match:
1> AddStaticLexerModule
1>x64\Debug\CustomLexer.exe : fatal error LNK1120: 1 unresolved externals
I think the problem is that AddStaticLexerModule is declared as a C++ function in Lexilla.h, but in Lexilla.cxx it is defined as an extern "C" function.
If I move the AddStaticLexerModule definition outside of the extern "C" block and rebuild liblexilla.lib, then my C++ application links successfully.
Committed fix with
https://github.com/ScintillaOrg/lexilla/commit/1179da2c996a1a961223c011c013ffcb1fb65bf0