Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIBHPDF_EXAMPLES #104

Closed
nilgoyette opened this issue Jul 3, 2015 · 11 comments
Closed

LIBHPDF_EXAMPLES #104

nilgoyette opened this issue Jul 3, 2015 · 11 comments
Labels

Comments

@nilgoyette
Copy link

While trying to test libHaru with Visual Studio, I came across this error when I activate LIBHPDF_EXAMPLES in cmake.

include\hpdf.h(464): error C2146: syntax error : missing ')' before identifier 'zoom'
include\hpdf.h(464): error C2081: 'HPDF_Boolean' : name in formal parameter list illegal
repeated often, probably for each example.
Intellisense tells me: Error: Identifier "HPDF_Boolean" is undefined

I tested with CMake 2.8 and 3.2, and with Visual Studio 2012 and 2013.

I tried adding #include "hpdf_objects.h" in hpdf.h because HPDF_Boolean seems to be defined here, but now I have redefinition errors. I'm not actually a C programmer so I don't know how to fix that.

@termi3
Copy link

termi3 commented Sep 12, 2015

Change HPDF_Boolean
to
HPDF_BOOL
for me it works :-)

@vdmit
Copy link

vdmit commented Sep 13, 2015

Type HPDF_Boolean is defined in include/hpdf_objects.h, and it is NOT a redefinition of HPDF_BOOL:

typedef struct _HPDF_Boolean_Rec  *HPDF_Boolean;

So proper fix is probably to add #include "hpdf_objects.h" into hpdf.h header file.

@termi3
Copy link

termi3 commented Sep 13, 2015

It works for compilation of the library and probably for some samples.
But for jpeg_demo it leads to redefinition as nilgoyyou mentioned.

@termi3
Copy link

termi3 commented Sep 15, 2015

I solved the problem as you proposed:
added in hpdf.h:
#include "hpdf_objects.h"

and for my case commented all redefined types in hpdf.h:
#ifdef HPDF_SHARED

#ifndef HPDF_EXPORT
#define HPDF_EXPORT(A) extern A
#endif /* HPDF_EXPORT */

#include "hpdf_consts.h"
#include "hpdf_types.h"

//#ifndef _HPDF_OBJECTS_H
typedef void *HPDF_HANDLE;
typedef HPDF_HANDLE HPDF_Doc;
//typedef HPDF_HANDLE HPDF_Page;
//typedef HPDF_HANDLE HPDF_Pages;
//typedef HPDF_HANDLE HPDF_Stream;
//typedef HPDF_HANDLE HPDF_Image;
typedef HPDF_HANDLE HPDF_Font;
//typedef HPDF_HANDLE HPDF_Outline;
//typedef HPDF_HANDLE HPDF_Encoder;
//typedef HPDF_HANDLE HPDF_3DMeasure;
//typedef HPDF_HANDLE HPDF_ExData;
//typedef HPDF_HANDLE HPDF_Destination;
//typedef HPDF_HANDLE HPDF_XObject;
//typedef HPDF_HANDLE HPDF_Annotation;
//typedef HPDF_HANDLE HPDF_ExtGState;
typedef HPDF_HANDLE HPDF_FontDef;
//typedef HPDF_HANDLE HPDF_U3D;
//typedef HPDF_HANDLE HPDF_JavaScript;
//typedef HPDF_HANDLE HPDF_Error;
//typedef HPDF_HANDLE HPDF_MMgr;
//typedef HPDF_HANDLE HPDF_Dict;
//typedef HPDF_HANDLE HPDF_EmbeddedFile;
//typedef HPDF_HANDLE HPDF_OutputIntent;
//typedef HPDF_HANDLE HPDF_Xref;
//#endif

#else

Now it works, and solve as well additional issue, which I had with the including u3d (this one
#108
And I have the changes in my forked version, but - I do not now HOW to commit these to the main version and IF I should do this?

@vdmit
Copy link

vdmit commented Sep 15, 2015

I'm not sure this "fix" is acceptable for upstream. There should be a reason for these type redefinitions. Maybe previous maintaner @tony2001 could answer this?
However, demos are built fine on Linux (GCC 4.8, CMake).

@termi3
Copy link

termi3 commented Sep 15, 2015

It was question - you probably build and link haru statically,
because the correction is within one
#ifdef HPDF_SHARED
block ?
I used CMake with VS2013 Community Eiditon on Win8.1 64 bit,
but probably was not good idea to select both "static and shared" lib...
I have to play with that.
image

@extensia
Copy link
Contributor

Having the same issue here using Windows and MinGW. Not sure what the proper fix is for this problem. It seems the typedefs related to exported library functions should have been defined in one place rather than split accross hpdf.h and hpdf_objects.h.

Any thoughts on how to proceed?

@extensia
Copy link
Contributor

After a little more poking around I see that HPDF_Boolean was introduced into hpdf.h by the commit large U3D-related patch by Michael Vidiassov made on Oct 30, 2013 by @tony2001. This seems to be the smoking gun rather than the typedefs @termi3 proposed in his fix.

I believe the change @termi3 initially suggested is the correct fix. As @vdmit noted, HPDF_BOOL and HPDF_Boolean have different definitions, but looking at how the boolean "zoom" parameter is actually used in the offending HPDF_Page_CreateXObjectFromImage function suggests this is a valid change:

From hdf_pages.c (line 680)

if (zoom) {

I propose changing the zoom parameter on HPDF_Page_CreateXObjectFromImage to HPDF_BOOL in both hpdf_pages.c and in hpdf.h. Any thoughts?

@mvidiassov
Copy link

I see that HPDF_Boolean was introduced into hpdf.h by the commit large U3D-related patch by Michael Vidiassov

Thank you for fixing my error.

@extensia
Copy link
Contributor

@mvidiassov my pleasure. Thanks for your many contributions!

@termi3
Copy link

termi3 commented Dec 25, 2015

@extensia - for me is your change OK. It seems I have not done correct my pull request for changing hpdf.h with the double definitions. I will try now again to create pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants