Writing wrappers for Python 3 vs Python 2 - c++

In Python, is there any difference in how one would write Python wrappers for c++ libraries if one aims to make it compatible with Py3 vs Py2?
Or should a wrapper originally written for Py2 work the same way for Py3 and visa versa? As I understand it, Python wrappers are written in c++ in a .cxx file which then have to be compiled.
Details
I ask because I'm wanting to install Aggdraw (wrapper for c++ Anti Grain Geometry drawing library), which works in Python 2.6-7, but results in errors on Python 3.4 (Windows 7 32-bit, via "PATH=C:/Python27[or Python34]" and "python setup.py install" in the command line). My hope is to revive this amazing wrapper module for Python 3, and was hoping anyone else here would be interesting in helping out.
I can get it compiled on Python 2.6 and 2.7 without any problems, and I have both Visual C++ 2008 and 2010 so it's not a compiler problem. The problem seems to be in the actual .cxx wrapper code.
Could it be that the Aggdraw wrapper was only written with Python 2x in mind (almost 10 years ago now), and so it didn't take into account problems that might arise in Python 3x? My best guess is that the wrapper fails to convert certain c++ objects/types over to Python due to deprecated and changed features in version 3.4.
I might be willing to go through the .cxx wrapper code to change the necessary parts, if someone can help me identify what the troubleparts are (see command line error codes below)? If we get it fixed then I'll update this post with a link to the "revived" wrapper code.
If there should´t be a difference between Python 2 and 3 wrappers, any idea why I´m getting the error codes below in Py3 but not Py2?
Thanks!
Original wrapper code: click here
C:\Users\BIGKIMO\Desktop\aggdraw-master>python setup.py build
=== freetype not available (edit setup.py to enable)
running install
running build
running build_ext
building 'aggdraw' extension
C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /
W3 /GS- /DNDEBUG -Iagg2/include -IC:\Python34\include -IC:\Python34\include /Tpa
ggdraw.cxx /Fobuild\temp.win32-3.4\Release\aggdraw.obj
aggdraw.cxx
aggdraw.cxx(124) : error C2440: 'initializing' : cannot convert from 'const char
[5]' to 'Py_ssize_t'
There is no context in which this conversion is possible
aggdraw.cxx(126) : error C2440: 'initializing' : cannot convert from 'destructor
' to 'printfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(128) : error C2440: 'initializing' : cannot convert from 'getattrfun
c' to 'setattrfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(142) : error C2440: 'initializing' : cannot convert from 'const char
[4]' to 'Py_ssize_t'
There is no context in which this conversion is possible
aggdraw.cxx(144) : error C2440: 'initializing' : cannot convert from 'destructor
' to 'printfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(161) : error C2440: 'initializing' : cannot convert from 'const char
[6]' to 'Py_ssize_t'
There is no context in which this conversion is possible
aggdraw.cxx(163) : error C2440: 'initializing' : cannot convert from 'destructor
' to 'printfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(187) : error C2440: 'initializing' : cannot convert from 'const char
[5]' to 'Py_ssize_t'
There is no context in which this conversion is possible
aggdraw.cxx(189) : error C2440: 'initializing' : cannot convert from 'destructor
' to 'printfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(191) : error C2440: 'initializing' : cannot convert from 'getattrfun
c' to 'setattrfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(207) : error C2440: 'initializing' : cannot convert from 'const char
[5]' to 'Py_ssize_t'
There is no context in which this conversion is possible
aggdraw.cxx(209) : error C2440: 'initializing' : cannot convert from 'destructor
' to 'printfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(211) : error C2440: 'initializing' : cannot convert from 'getattrfun
c' to 'setattrfunc'
This conversion requires a reinterpret_cast, a C-style cast or function-
style cast
aggdraw.cxx(488) : error C3861: 'PyString_Check': identifier not found
aggdraw.cxx(489) : error C3861: 'PyString_AS_STRING': identifier not found
aggdraw.cxx(575) : error C3861: 'PyString_Check': identifier not found
aggdraw.cxx(583) : error C3861: 'PyString_AS_STRING': identifier not found
aggdraw.cxx(584) : error C3861: 'PyString_GET_SIZE': identifier not found
aggdraw.cxx(730) : error C3861: 'PyInt_Check': identifier not found
aggdraw.cxx(730) : error C3861: 'PyInt_AS_LONG': identifier not found
aggdraw.cxx(731) : error C3861: 'PyInt_Check': identifier not found
aggdraw.cxx(731) : error C3861: 'PyInt_AS_LONG': identifier not found
aggdraw.cxx(735) : error C3861: 'PyInt_Check': identifier not found
aggdraw.cxx(735) : error C3861: 'PyInt_AS_LONG': identifier not found
aggdraw.cxx(736) : error C3861: 'PyInt_Check': identifier not found
aggdraw.cxx(736) : error C3861: 'PyInt_AS_LONG': identifier not found
aggdraw.cxx(742) : error C3861: 'PyInt_Check': identifier not found
aggdraw.cxx(742) : error C3861: 'PyInt_AS_LONG': identifier not found
aggdraw.cxx(745) : error C3861: 'PyInt_Check': identifier not found
aggdraw.cxx(745) : error C3861: 'PyInt_AS_LONG': identifier not found
aggdraw.cxx(759) : error C3861: 'PyInt_Check': identifier not found
aggdraw.cxx(760) : error C3861: 'PyInt_AsLong': identifier not found
aggdraw.cxx(763) : error C3861: 'PyString_Check': identifier not found
aggdraw.cxx(765) : error C3861: 'PyString_AS_STRING': identifier not found
aggdraw.cxx(788) : error C3861: 'PyString_Check': identifier not found
aggdraw.cxx(789) : error C3861: 'PyString_AS_STRING': identifier not found
aggdraw.cxx(1157) : error C3861: 'PyString_FromStringAndSize': identifier not fo
und
aggdraw.cxx(1289) : error C3861: 'PyString_FromString': identifier not found
aggdraw.cxx(1294) : error C3861: 'Py_FindMethod': identifier not found
aggdraw.cxx(1482) : error C3861: 'Py_FindMethod': identifier not found
aggdraw.cxx(1890) : error C3861: 'Py_FindMethod': identifier not found
aggdraw.cxx(1910) : error C3646: 'initaggdraw' : unknown override specifier
aggdraw.cxx(1911) : error C2091: function returns function
aggdraw.cxx(1911) : error C4430: missing type specifier - int assumed. Note: C++
does not support default-int
aggdraw.cxx(1912) : error C2039: 'ob_type' : is not a member of '_typeobject'
c:\python34\include\object.h(334) : see declaration of '_typeobject'
aggdraw.cxx(1912) : error C2039: 'ob_type' : is not a member of '_typeobject'
c:\python34\include\object.h(334) : see declaration of '_typeobject'
aggdraw.cxx(1913) : error C2039: 'ob_type' : is not a member of '_typeobject'
c:\python34\include\object.h(334) : see declaration of '_typeobject'
aggdraw.cxx(1913) : error C2039: 'ob_type' : is not a member of '_typeobject'
c:\python34\include\object.h(334) : see declaration of '_typeobject'
aggdraw.cxx(1913) : error C2039: 'ob_type' : is not a member of '_typeobject'
c:\python34\include\object.h(334) : see declaration of '_typeobject'
aggdraw.cxx(1915) : error C3861: 'Py_InitModule': identifier not found
aggdraw.cxx(1940) : warning C4508: 'DL_EXPORT' : function should return a value;
'void' return type assumed

The Python FFI library (ctype) has changes between each version of python. It would be up to you to go through the change list and see what exactly is different and why it isn't working.
For example, ssizet and strings are different between the two Python versions.
https://docs.python.org/3/whatsnew/3.2.html#ctypes
Differences in ctypes between Python 2 and 3

In the interest of expanding upon the previous answer, there are many functions which acted upon string in Py2.7 and now act upon bytes or unicode in Py3. Similarly, what referred to int may now refer to long. As just one example of this that caused a problem here, PyString_Check has been deprecated by pyBytes_Check. Read the following for more details:
https://docs.python.org/3/howto/cporting.html?highlight=pystring

Related

Having issues with linking to boost library (C++ in Visual Studio 2013)

I have been banging my head on this for a few days now. I tried downloading and compiling the latest boost 1.67.0, to include
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/process.hpp>
But I got the errors seen below when trying to compile (one thing I noticed about it is that the path has slashes going the wrong way in the error log and Im not sure how to fix that?
I tried compiling with standard cmd and also Visual Studio 2013 prompt (same result).
I then tried grabbing the precompiled version from boost site
boost_1_67_0-msvc-12.0-32.exe
And am still getting the same problem. The #include text is not underlined in the editor. And I have additional include directories pointing to:
C:\VisualStudioLibraries\boost_1_67_0
and Linker Additional Library Directories to
C:\VisualStudioLibraries\boost_1_67_0\stage\lib
Does anyone know how to resolve this? If I comment out the #include lines for boost the code compiles without any issues and program runs. My code doesnt use anything from boost yet, so the only boost related stuff in there are the 3 #include lines.
Errors are:
1> MyForm.cpp
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(65): error C3646: 'noexcept' : unknown override specifier
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(72): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(77): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(82): error C2440: '' : cannot convert from 'std::error_code' to 'boost::process::process_error'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(88): error C2440: '' : cannot convert from 'const std::error_code' to 'boost::process::process_error'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(94): error C2660: 'boost::process::process_error::process_error' : function does not take 2 arguments
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C2146: syntax error : missing ';' before identifier 'Char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C2146: syntax error : missing ';' before identifier 'null_char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(97): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(98): error C2144: syntax error : 'char' should be preceded by ';'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(98): error C2143: syntax error : missing ';' before '<'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(99): error C2143: syntax error : missing ';' before '{'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(99): error C2447: '{' : missing function header (old-style formal list?)
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C2146: syntax error : missing ';' before identifier 'Char'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C2146: syntax error : missing ';' before identifier 'equal_sign'
1>C:\VisualStudioLibraries\boost_1_67_0\boost/process/detail/config.hpp(101): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Thank you all very much.
Well, Im sure this is not the answer most will want to hear, but after trying for over a week to get it to work the only thing that ended up working was to move on to Visual Studio 2017. Everything linked and compiled fine there. Perhaps there is an issue with my VS2013 install (but everything else works flawlessly on it).

Tesseract 3.05 Build errors in Visual Studio 2017

I used the solution provided here in order to make Tesseract 3.05 work on my windows10 x64 project, visual studio 2017.
I got these errors when building it:
11>c:\users\mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unichar.h(164): error C3646: 'UTF32ToUTF8': unknown override specifier
11>c:\users\mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unichar.h(164): error C2059: syntax error: 'const'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unichar.h(164): error C2238: unexpected token(s) preceding ';'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\genericvector.h(376): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\params.h(205): warning C4800: 'BOOL8': forcing value to bool 'true' or 'false' (performance warning)
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(241): error C3646: 'CleanupString': unknown override specifier
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(241): error C2059: syntax error: 'const'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(241): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(244): error C3646: 'CleanupString': unknown override specifier
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(244): error C2059: syntax error: 'const'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(244): error C2238: unexpected token(s) preceding ';'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(265): error C2065: 'string': undeclared identifier
11>c:\users\mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(265): error C2146: syntax error: missing ';' before identifier 'cleaned'
11>c:\users\ mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(265): error C2065: 'cleaned': undeclared identifier
11>c:\users\mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(265): error C3861: 'CleanupString': identifier not found
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\unicharset.h(266): error C2065: 'cleaned': undeclared identifier
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(181): error C3646: 'VersionString': unknown override specifier
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(181): error C2059: syntax error: '('
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(181): error C2238: unexpected token(s) preceding ';'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(183): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(183): error C2143: syntax error: missing ',' before '&'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(134): error C2664: 'void tesseract::TessdataManager::SetVersionString(const int)': cannot convert argument 1 from 'const char [13]' to 'const int'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(134): note: There is no context in which this conversion is possible
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(138): error C2664: 'void tesseract::TessdataManager::SetVersionString(const int)': cannot convert argument 1 from 'const char [13]' to 'const int'
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\ccutil\tessdatamanager.h(138): note: There is no context in which this conversion is possible
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\dict\dict.h(55): warning C4566: character represented by universal-character-name '\u2606' cannot be represented in the current code page (1252)
11>c:\users\jihed mestiri\documents\vs2015_tesseract-master\vs2015_tesseract-master\tesseract_3.05\api\tesseractmain.cpp(34): fatal error C1083: Cannot open include file: 'simddetect.h': No such file or directory
11>Done building project "tesseract.vcxproj" -- FAILED.
========== Build: 9 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========
How to resolve them?
Since the time of the linked answer, project structure was changed. It's updated to Tesseract 3.05 and clear Git submodule links to the proper Leptonica and tesseract_3.05 sources added.
It looks like you've downloaded master sources for both of them. At the moment VS2015_Tesseract is not compatible with it.
Proper dependency links are: leptonica # e98a794 and tesseract_3.05 # 7fe95f0. Download it and try to rebuild the solution.
After adding in C/C++ -> Additional Include libraries:
C:\Users\Jihed Mestiri\Documents\VS2015_Tesseract-master\liblept
C:\Documents\VS2015_Tesseract-master\leptonica\src
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\wordrec
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\opencl
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\viewer
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\textord
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\neural_networks\runtime
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\dict
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\cutil
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\cube
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\classify
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\ccstruct
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\ccutil
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\ccmain
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\api
C:\Users\Documents\VS2015_Tesseract-master\tesseract_3.05\vs2010\port
as well as the directory that contains .lib files in Linker -> General -> Additional Library directories and included in Linker -> Input -> Additional dependencies these .lib files of Tesseract and Leptonica:
libtesseract.lib
giflib.lib
libjpeg.lib
liblept.lib
libpng.l‌​ib
libtiff.lib
li‌​bwe‌​bp.lib
openjpeg.lib
‌​zlib.lib
Compilation errors of my test program changed to:
1>------ Build started: Project: RedEyeRemover, Configuration: Debug x64 ------
1>LINK : fatal error LNK1104: cannot open file 'libpng.l‌​ib'
1>Done building project "RedEyeRemover.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Whereas the directory that contains libpng.lib file is included in Linker->General.
The parameters are taken from tesseract/tesseract.vcxproj that I build from VS2015_Tesseract
What can be the reason behind that error? and is there a way to verify that tesseract.vcxproj is working correctly at its own? because I get errors when I compile it too on Visual Studio 2017 (using v140 = VS 2015 version for build) on x64 target.
EDIT: SOLUTION: I discovered that the problem was in Linker -> General -> Additional Library directories where I had a space in one of the parent directory of the path e.g: "xxx xxx/tesseract". => avoid using paths with space.

I'm trying to add an external library to a Source mod, and I'm having some trouble

I'm trying to add this Serial Communications library to the Source SDK code to try to integrate my own serial input into Steam games. I've got the example projects on the Serial library I downloaded working fine. I added the Serial project to the Source solution and gave the "Server (HL2)" project a dependency to it (I'm using Visual Studio 2013 Express). I then went to my .cpp file under the Server (HL2) project and simply added
#include "Serial.h"
#define STRICT
#include <tchar.h>
#include <stdio.h>
#include <string.h>
which are the headers defined in the example project that was working for me, and got a lot of errors when I went to compile. The errors are all along the lines of:
\serial.h(190): error C2065: 'CE_RXOVER' : undeclared identifier
\serial.h(191): error C2065: 'CE_RXPARITY' : undeclared identifier
\serial.h(193): error C2065: 'CE_TXFULL' : undeclared identifier
\serial.h(215): error C2061: syntax error : identifier 'LPCTSTR'
\serial.h(220): error C2146: syntax error : missing ';' before identifier 'Open'
\serial.h(220): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
\serial.h(220): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(220): error C2061: syntax error : identifier 'LPCTSTR'
\serial.h(220): warning C4183: 'Open': missing return type; assumed to be a member function returning 'int'
\serial.h(223): error C2146: syntax error : missing ';' before identifier 'Close'
\serial.h(223): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
\serial.h(223): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(223): warning C4183: 'Close': missing return type; assumed to be a member function returning 'int'
\serial.h(241): error C2146: syntax error : missing ';' before identifier 'Setup'
\serial.h(241): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
\serial.h(241): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(244): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\serial.h(244): warning C4183: 'Setup': missing return type; assumed to be a member function returning 'int'
\serial.h(250): error C2146: syntax error : missing ';' before identifier 'SetEventChar'
\serial.h(250): error C2433: 'CSerial::LONG' : 'virtual' not permitted on data declarations
They repeat and then...
\serial.h(361): error C2061: syntax error : identifier 'LPOVERLAPPED'
\serial.h(329): error C2065: 'm_lLastError' : undeclared identifier
\serial.h(345): error C2065: 'DCBlength' : undeclared identifier
\serial.h(345): error C2065: 'DCB' : undeclared identifier
\serial.h(345): error C2070: 'unknown-type': illegal sizeof operand
There's also a whole lot more "undeclared identifiers" where that came from. I feel like there's a very obvious solution somewhere, either the way I have the solution set up or the linker or something. But it finds the file, it's just not interpreting it correctly it seems. When I take out
#include "Serial.h"
It compiles fine, so it has something to do with the way I'm adding that new header file. Any help would be much appreciated.

Visual Studio 2013 - C++ Errors

Some strange things happen. When I compile my program in Dev-C++ it gives me no errors and compiles clean. When I put it in Visual Studio I got a LOT of errors:
Error 1 error C2371: 'MailRecipient' : redefinition; different basic types
Error 2 error C3861: 'GetModuleFileName': identifier not found
Error 3 error C2664: 'HRESULT SHGetFolderPathW(HWND,int,HANDLE,DWORD,LPWSTR)' : cannot convert argument 5 from 'char [260]' to 'LPWSTR'
Error 4 error C3861: 'CopyFile': identifier not found
Error 5 error C2664: 'BOOL SetFileAttributesW(LPCWSTR,DWORD)' : cannot convert argument 1 from 'char [512]' to 'LPCWSTR'
Error 6 error C2664: 'HRESULT SHGetFolderPathW(HWND,int,HANDLE,DWORD,LPWSTR)' : cannot convert argument 5 from 'char [260]' to 'LPWSTR'
Error 7 error C2664: 'BOOL SetFileAttributesW(LPCWSTR,DWORD)' : cannot convert argument 1 from 'char []' to 'LPCWSTR'
Error 8 error C2664: 'LSTATUS RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY)' : cannot convert argument 2 from 'const char [46]' to 'LPCWSTR'
Error 9 error C2664: 'HRESULT SHGetFolderPathW(HWND,int,HANDLE,DWORD,LPWSTR)' : cannot convert argument 5 from 'char [260]' to 'LPWSTR'
Error 10 error C2664: 'LSTATUS RegSetValueExW(HKEY,LPCWSTR,DWORD,DWORD,const BYTE *,DWORD)' : cannot convert argument 2 from 'const char [9]' to 'LPCWSTR'
It all works on Dev-C++ tho. I need to compile it in VS because I want to add something from the POCO library, which, ironically, doesn't compile in Dev-C++... Any help?
A Visual Studio project defines UNICODE by default.
You can either turn off Unicode in the project settings, or rework your program to use wchar_t based strings (e.g. L"Blah" instead of "Blah").
Or, you can #undef UNICODE before including <windows.h>, every place.
There seem to be some issues about #include statements in your Project. You need to figure out why MailRecipient gets redefined. You will probably have to adjust some of the project settings in Visual Studio. Also, as the first answer suggests Visual Studio uses UNICODE by default, which causes it to call the wide string versions of Windows API functions. You can use the std::widen function to convert your strings just for Windows API calls. For more information on this topic see utf8everywhere.org.

RPC_CSTR' : undeclared identifier while compile c++ using Nmake

I use rpcrt4.lib to generate dll. While generate dll using nmake ( cl.exe compiler) in Visual studio 2003 .Net, getting following error
nstaller\UUIDGenerator.cpp(35) : error C2065: 'RPC_CSTR' : undeclared identifier
installer\UUIDGenerator.cpp(35) : error C2059: syntax error : ')'
installer\UUIDGenerator.cpp(68) : error C2059: syntax error : ')'
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Cause :
I use following function
UuidToStringA(&uuid, (RPC_CSTR*)&str);
You need to link to rpcrt4.lib, which it sounds like you did.
But you also need to:
#include "Rpcdce.h"
This error
error C2065: 'RPC_CSTR' : undeclared identifier
Means that it doesn't know if this is a class, variable name, etc. That's why it needs the header file.