C++ - Using Hunspell with MFC
-
24-05-2021 - |
Domanda
After I managed to get Hunspell working with a Win32 console application, I want to use Hunspell in an MFC application in the same solution. I get the following error when I try to compile the MFC application.
spellcheck\hunspell-src\hunspell\replist.hxx(23): error C2062: type 'const char' unexpected
spellcheck\hunspell-src\hunspell\replist.hxx(23): error C2238: unexpected token(s) preceding ';'
Some information about the solution:
- The solution is called spellcheck.
- The Hunspell source files are located in
spellcheck\hunspell-src\hunspell
andspellcheck\hunspell-src\win_api
. - The project
libhunspell
has been imported and compiles without errors. - A console application in the solution uses the same hunspell dll/source files and has no errors.
- The console application has been setup accordingly to this thread
- The folders
HunSpell-Src
andHunSpell-Dic
are NOT located in a project folder but in the solution folderspellcheck
and referenced properly.
I have setup the MFC application as following:
- Added a new MFC application (SDI) as project to the solution called
MFC2
. - Added a reference to the project
libhunspell
toMFC2
. Project > Properties > Configuration Properties > C++ > General > Additional Include Directories
has been set to:..\hunspell-src\hunspell;%(AdditionalIncludeDirectories)
(the same as the console application)Project > Properties > Configuration Properties > Linker > General > Additional Library Directories
has been set to:..\hunspell-src\win_api\Debug_dll\libhunspell;%(AdditionalLibraryDirectories)
(the same as the console application)- Added
#include "../HunSpell-Src/win_api/hunspelldll.h"
under#include MainFrm.h
inMainfrm.cpp
.
I decided to put the #include of hunspelldd.h
in Mainfrm.cpp
and omit setting up a dialog and calling it in order to keep this question as short as possible. Nevertheless I have setup a project as described that produces said error messages.
Because the console application compiles fine, I assume something MFC specific is causing the problem.
Thank you for your help.
Soluzione
Add "#undef near" before class declaration in replist.hxx
Altri suggerimenti
I'd look for an error in the include file just before replist.hxx, perhaps a missing ending semicolon on a class definition.