Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Errors C2664 & C2065 when mixing XML/C++ library and another one

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi!

I am working with Visual C++ 6.0 on NT4.0 SP6a.

I am trying to 'integrate' Apache Xerces for C++ (xerces-c.lib) with
another tested library (another.lib).

I've got no problem working with 'xerces-c.lib' alone: I setup the environment
by going Project>Settings>Link>xerces-c.lib, creating DOMCount.cpp, compiling, ...

I've got no problem working with 'another.lib' alone: I setup the environment
by going Project>Settings>Link>another.lib, creating another.c, compiling, ...

The problem comes when mixing both. I cut&paste pieces from another.c to
another.c. I include every header files (xxx.h):

/*Includes from DOMCount.cpp*/
#include <util/PlatformUtils.hpp>
#include <sax/SAXException.hpp>
#include <sax/SAXParseException.hpp>
#include <parsers/DOMParser.hpp>
#include <dom/DOM_DOMException.hpp>
#include &quot;DOMCount.hpp&quot;
#include <string.h>
#include <stdlib.h>
#include <dom/DOM_NodeList.hpp>
#include <dom/DOM.hpp>

/*Standard Includes*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <fcntl.h>
#include <fstream.h>
#include <iostream.h>

/*includes from another.c*/
#include <yyy.h>
#include <xxx.h>

...but I bump into this errors:

Compiling...
DOMCount.cpp
c:\xxx.h(19) : error C2664: 'fopen' : cannot convert parameter 1 from 'void *' to 'const char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
c:\xxx.h(192) : error C2065: 'min' : undeclared identifier
c:\xxx.h(357) : error C2664: 'open' : cannot convert parameter 1 from 'void *' to 'const char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast

Where xxx.h is a header file of 'another.lib':

line

15 void *mywrite_fopen (void *path,char *accessmodes)
...
19 if ((tfile=fopen(path,accessmodes))==NULL) return(NULL);

192 short odioreadbufs=min(8,MAXODIOBLOCKS);

350 void *myread_fopen(void *path)
...
357 if ((f->handle=open(path,READFLAGS))==-1) {

If you look at C++ specifications:
FILE *fopen(const char *name, const char *mode)

It's clear: you can not convert path from void* (in the declaration of
mywrite_fopen) to char* (in the common 'fopen' use). But WHY this error
does not happen when compiling separately? HOW can I solve it?

Any suggestion? Thanx.
 
Change line 19 to:

if((tfile=fopen( (char *) path, accessmodes))....

You can cast void pointers, just put (char *) or (int *) or whatever type you want to cast it to. As for the error on line 192, you need to #include<math.h> or whatever file the function min() is included in...

hth
MWB.


Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top