On Thu, 2009-07-16 at 09:46 +0200, Mirco Babin wrote:
> Hello,
>
> When compiling PoDoFo with Borland (nowadays Codegear) the following
> 25 adjustments have to be made:
If you're using a legacy compiler, it'd be really helpful if you could
minimise the maintenance work required to keep it working in trunk by
sending patches friendly to modern compilers too. Appropriate
conditional compilation guards etc will do the job.
I've applied many of these changes in svn trunk, and added a new
PdfCompilerCompat.h header that tries to isolate as much of the uglyness
as possible. Can you please re-test with current trunk and let me know
what else, if anything, needs changing?
You'll need to update your code to use svn trunk instead of 0.7.0. I
will not make these changes in the 0.7.0 branch.
Note that you will now have to add $SRCDIR/podofo/compilercompat/borland
to your header search path. If you can send me your CMakeCache.txt I may
be able to get CMake to do this for you automatically when it detects
Borland.
> 9) Build PoDoFo
> md PoDoFo-dll
> cd PoDoFo-dll
> cmake -G "Borland Makefiles" ..\podofo
> -DCMAKE_INCLUDE_PATH=..\zlib;..\jpeg;..\freetype\include
> -DCMAKE_LIBRARY_PATH=..\zlib;..\jpeg;..\freetype\objs
> -DPODOFO_BUILD_SHARED=TRUE
> 9.01) Edit PdfVariant.h (error: call to undefined function floor)
> Replace #include <cmath> with #include <math.h>
Your compiler is broken.
The C++ standard specifies <cmath> as the standard header. <math.h> is
supported as a backward compatibility kludge.
I'll add includes/compat/borland with dummy headers for this compiler.
It would be really helpful if you could send me your CMakeCache.txt so I
can see how to detect bcc and add the include path.
> 9.02) Edit PdfOutputDevice.h (error on FILE*):
> #include <stdio.h>
PdfDefines.h includes <cstdio>, which is the same thing with the ISO C++
name.
If borland doesn't have <cstdio> a compat wrapper will need to be
included for it too.
> 9.03) Edit PdfDate.h (error on time_t):
> #include <time.h>
Ditto 9.02
> 9.04) Edit PdfColor.cpp (error on _stricmp, memcpy, islower):
> #include <mem.h>
> #include <ctype.h>
Done.
> Replace "_stricmp" with "stricmp"
You must be using an old Borland compiler. MS has been doing the
underscore-prefixing of function names since ... forever.
I've added a compat wrapper for case insensitive compare in the new
header file PdfCompilerCompat.h, where I've just moved most of the
compiler compatibility uglyness.
Please add an appropriate clause for Borland if the existing tests don't
work.
> 9.05) Edit PdfDate.cpp (error on snprintf):
> #include <stdio.h>
Ditto 9.02
> 9.06) Edit PdfDifferenceEncoding.cpp (error on snprintf):
> #include <stdio.h>
Ditto 9.02
> 9.07) Edit PdfInputStream.h (error on FILE*):
> #include <stdio.h>
Ditto 9.02
> 9.08) Edit PdfEncrypt.cpp (error on memcmp,memcpy
> #include <mem.h>
Done.
> Comment out in the MD5 part: //#include <sys/types.h>
I presume you mean that Borland doesn't have sys/types.h ?
If you leave the MD5 part enabled but comment out the include of
sys/types.h, what breaks? Can you provide error messages? Is there an
appropriate alternative header you can use (which we can add to
PdfCompilerCompat.h) ?
> 9.09) Edit PdfField.cpp
> void PdfCheckBox::SetChecked( bool bChecked )
> {
> m_pObject->GetDictionary().AddKey( PdfName("V"), (bChecked ?
> PdfName("Yes") : PdfName("Off")) );
> m_pObject->GetDictionary().AddKey( PdfName("AS"),
> (bChecked ? PdfName("Yes") : PdfName("Off")) );
> }
What've you changed? Why?
> 9.10) Edit PdfFiltersPrivate.cpp (error on memset,memcpy)
> #include <mem.h>
Done.
> 9.11) Edit PdfFontMetrics.cpp (error on strncasecmp)
> void PdfFontMetrics::SetFontTypeFromFilename( const char*
> pszFilename )
> Replace "#ifdef _MSC_VER" with "#ifdef _WIN32"
No such directive in trunk.
> Replace "_strnicmp" with "strnicmp"
Not in trunk.
> 9.12) Edit PdfFontTTFSubset.cpp (error on _stricmp)
> Replace "_stricmp" with "stricmp"
Fixed.
> 9.13) Edit PdfImage.cpp (error on "multiple declaration for
> 'boolean'", strncasecmp)
> In the top, adjust the inclusion of jpeglib.h
> #ifdef PODOFO_HAVE_JPEG_LIB
> #define XMD_H
> #define HAVE_BOOLEAN
> extern "C" {
> #include "jpeglib.h"
> }
> #endif // PODOFO_HAVE_JPEG_LIB
This should be sorted.
> Replace "#ifdef _MSC_VER" with "#ifdef _WIN32"
Not in trunk.
> Replace "_strnicmp" with "strnicmp"'
Fixed.
> 9.14) Edit PdfInputStream.cpp (error on memcpy)
> #include <mem.h>
Fixed.
> 9.15) Edit PdfMemStream.cpp (error on memcpy)
> #include <mem.h>
Fixed.
> 9.16) Edit PdfOutputDevice.cpp (error on memcpy)
> #include <mem.h>
Fixed.
> 9.17) Edit PdfOutputStream.h (error on FILE*)
> #include <stdio.h>
Fixed.
> 9.18) Edit PdfOutputStream.cpp (error on memcpy)
> #include <mem.h>
Fixed.
> 9.19) Edit PdfParser.cpp (error on free)
> Replace "#include <cstdlib>" with "#include <stdlib.h>"
As 9.02
> 9.20) Edit PdfRefCountedBuffer.cpp (error on memcpy,memcmp)
> #include <mem.h>
Fixed.
> 9.21) Edit PdfRijndael.cpp (error on memcpy,memset)
> #include <mem.h>
Fixed.
> 9.22) Edit PdfTable.h (error on memcpy)
> #include <mem.h>
Fixed.
> 9.23) Edit PdfTokenizer.cpp (error on memset,isdigit, __FUNCTION__)
> #include <mem.h>
Fixed.
> #include <ctype.h>
Fixed.
> Replace "__FUNCTION__" with "__FUNC__"
Compat wrapper PODOFO__FUNCTION__ added. Please add your own clause to
PdfCompilerCompat that checks for the Borland compiler.
> 9.24) Edit test\PdfError_Test.cpp (error on printf)
> #include <stdio.h>
Fixed.
> 9.25) Edit test\PdfString_Test.cpp (error on memcpy)
> When opening this file the editor complains about codepage
> problems.
Not in trunk.
> So adjust test\PdfTest.h and #include <mem.h>
Fixed.
> "#ifdef _MSC_VER" is used in stead of "#ifdef _WIN32"
Often correctly, eg for _prefixed names.
> The _stricmp and _strnicmp functions should be strcmp and strnicmp
No, they shouldn't. The canonical win32 names are "_stricmp" and
"_strnicmp" according to MSDN and MSVC. Compat wrappers can be added for
Borland since it's relatively non-intrusive.
> 3) When snprintf or printf is used the #include <stdio.h> is missing
This is a bug in PoDoFo, thanks for pointing out the occurrances. Most
compilers let you get away with it.
> 4) When islower or isdigit is used the #include <ctype.h> is missing
This is a bug in PoDoFo, thanks for pointing out the occurrances. Most
compilers let you get away with it.
> 5) When FILE* structure is used the #include <stdio.h> is missing
This is a bug in PoDoFo, thanks for pointing out the occurrances. Most
compilers let you get away with it.
> 6) When time_t structure is used the #include <time.h> is missing
This is a bug in PoDoFo, thanks for pointing out the occurrances. Most
compilers let you get away with it.
> 7) The "floor" function is defined in math.h (and not <cmath>)
I suspect Borland's compiler of being broken here. Please add a
directive to PdfCompilerCompat.h that tests for Borland and includes
"math.h".
> 8) The 9.8 and 9.9 problems are real bugs.
9.8 ... no idea.
9.9 - you didn't provide a diff or show what you changed from. Looks
like your code in trunk.
> 9) The 9.13 problem with the LIBJPEG header was also a problem when
> compiling with MinGW
Yep.
> I hope this can be fixed.
It should be. It'd be REALLY helpful, in future, if you'd think about
your changes in terms of _all_ platforms/compilers not just "hack it to
work with Borland". It makes it much harder for me / dom to merge the
changes you need if we have to fix them all up so they won't break
everything else.
--
Craig Ringer
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users