473,320 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

is it really that complicated ?

I am trying my best here to understand the following that you will
find in the header file of expat.h

typedef void (XMLCALL *XML_ElementDeclHandler) (...);

Now for starters what is XMLCALL i dont want to know what it does i
only want to know wat it is ? pointer, integer ?

Next questioin would be whats with all this (XMLCALL
*XML_ElementDeclHandler) ?
Why can it not be somthing like this ?

typedef XMLCALL XML_ElementDeclHandler(...);

And what about this ?

XMLPARSEAPI (const XML_Char *)
XML_GetBase(...);

Why not

XMLPARSEAPI
XML_GetBase(...);

Now about the example part.

static void XMLCALL
startElement(...){...}

Why not like

static XMLCALL
startElement(...){...}

Jul 13 '07 #1
8 1630
On Jul 12, 5:22 pm, gert <gert.cuyk...@gmail.comwrote:
I am trying my best here to understand the following that you will
find in the header file of expat.h

typedef void (XMLCALL *XML_ElementDeclHandler) (...);

Now for starters what is XMLCALL i dont want to know what it does i
only want to know wat it is ? pointer, integer ?
As a wild guess, I would venture:
/* Expat tries very hard to make the API boundary very specifically
defined. There are two macros defined to control this boundary;
each of these can be defined before including this header to
achieve some different behavior, but doing so it not recommended or
tested frequently.

XMLCALL - The calling convention to use for all calls across the
"library boundary." This will default to cdecl, and
try really hard to tell the compiler that's what we
want.

XMLIMPORT - Whatever magic is needed to note that a function is
to be imported from a dynamically loaded library
(.dll, .so, or .sl, depending on your platform).

The XMLCALL macro was added in Expat 1.95.7. The only one which is
expected to be directly useful in client code is XMLCALL.

Note that on at least some Unix versions, the Expat library must be
compiled with the cdecl calling convention as the default since
system headers may assume the cdecl convention.
*/
#ifndef XMLCALL
#if defined(_MSC_VER)
#define XMLCALL __cdecl
#elif defined(__GNUC__) && defined(__i386) && !
defined(__INTEL_COMPILER)
#define XMLCALL __attribute__((cdecl))
#else
/* For any platform which uses this definition and supports more than
one calling convention, we need to extend this definition to
declare the convention used on that platform, if it's possible to
do so.

If this is the case for your platform, please file a bug report
with information on how to identify your platform via the C
pre-processor and how to specify the same calling convention as the
platform's malloc() implementation.
*/
#define XMLCALL
#endif
#endif /* not defined XMLCALL */

Next questioin would be whats with all this (XMLCALL
*XML_ElementDeclHandler) ?
Why can it not be somthing like this ?

typedef XMLCALL XML_ElementDeclHandler(...);
Because that would not be the same.
And what about this ?

XMLPARSEAPI (const XML_Char *)
XML_GetBase(...);

Why not

XMLPARSEAPI
XML_GetBase(...);

Now about the example part.

static void XMLCALL
startElement(...){...}

Why not like

static XMLCALL
startElement(...){...}
Ask the package authors about the API choices. Pull out a C manual
and find out what these things mean. You will find that it is faster
than asking here.

P.S.

int foo(void); /* this is a function prototype for a function that
takes no arguments and returns an integer value */

typedef int (*bar)(void); /* This is a typedef for an function pointer
returning int. We could assign foo to an instance of it. */

Jul 13 '07 #2
On Jul 13, 2:49 am, user923005 <dcor...@connx.comwrote:
On Jul 12, 5:22 pm, gert <gert.cuyk...@gmail.comwrote:
I am trying my best here to understand the following that you will
find in the header file of expat.h
typedef void (XMLCALL *XML_ElementDeclHandler) (...);
Now for starters what is XMLCALL i dont want to know what it does i
only want to know wat it is ? pointer, integer ?

As a wild guess, I would venture:
#define XMLCALL __cdecl
#define XMLCALL __attribute__((cdecl))
http://www.linuxcommand.org/man_pages/cdecl1.html

Ok and cdecl would be like a pointer, or more like a integer ?
Come on its killing me, that's like melons and oranges, not to mention
the ((cdecl))
Next questioin would be whats with all this (XMLCALL
*XML_ElementDeclHandler) ?
Why can it not be somthing like this ?
typedef XMLCALL XML_ElementDeclHandler(...);

Because that would not be the same.
And what about this ?
XMLPARSEAPI (const XML_Char *)
XML_GetBase(...);
Why not
XMLPARSEAPI
XML_GetBase(...);
Now about the example part.
static void XMLCALL
startElement(...){...}
Why not like
static XMLCALL
startElement(...){...}

Ask the package authors about the API choices. Pull out a C manual
and find out what these things mean. You will find that it is faster
than asking here.
Well the manual goes like this :)
typedef int NUMBER;

I can still live with something like
typedef int * NUMBER;

And maybe if my brains are like cooled down with ice i can figure out
a function pointer that looks like a cast but isn't a cast. But still
i expect a name for the function pointer

typedef int (*bar)(void) MYFUNCTION;

There must be a other way to write the following in a more convenient
way ?

typedef void (XMLCALL *XML_ElementDeclHandler) (...);

Jul 13 '07 #3
gert said:

<snip>
Well the manual goes like this :)
typedef int NUMBER;

I can still live with something like
typedef int * NUMBER;

And maybe if my brains are like cooled down with ice i can figure out
a function pointer that looks like a cast but isn't a cast. But still
i expect a name for the function pointer

typedef int (*bar)(void) MYFUNCTION;
No, that isn't how it works.

Start off by choosing a name.

foo

Now make it a function type:

int foo(void);

But we want a pointer to function, rather than a function:

int (*foo)(void);

But we want a type, rather than an object. So *now* we put typedef on
the front.

typedef int (*foo)(void);

See?
There must be a other way to write the following in a more convenient
way ?

typedef void (XMLCALL *XML_ElementDeclHandler) (...);
Sure. Delete the spurious XMLCALL thingy which is making this so
unreadable. Alternatively, live with it.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 13 '07 #4
"gert" <ge**********@gmail.comwrote in message
news:11*********************@n60g2000hse.googlegro ups.com...
>As a wild guess, I would venture:
#define XMLCALL __cdecl
#define XMLCALL __attribute__((cdecl))
....
Ok and cdecl would be like a pointer, or more like a integer ?
Did you not read the part of the comments in expat.h that said "cdecl" is a
calling convention? It's not a type.

(And, of course, calling conventions are off-topic here, but as a general
rule if you don't know what those are, you can safely just copy other,
similar code and/or follow the directions.)
Come on its killing me, that's like melons and oranges, not to
mention the ((cdecl))
That's just some screwy syntax related to GCC's __attribute__ extension.

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

Jul 13 '07 #5
i found the mother load of information about function pointer
http://gethelp.devx.com/techtips/cpp.../10min0300.asp

It explains allot, but still this doesn't fit in ?

http://expat.cvs.sourceforge.net/exp....h?view=markup
This is what is written on line 725 of expat.h ?

XMLPARSEAPI(const XML_Char *) XML_GetBase(XML_Parser parser);

Any idea what's XMLPARSEAPI(...) does ?

Jul 13 '07 #6
gert <ge**********@gmail.comwrote:
i found the mother load of information about function pointer
http://gethelp.devx.com/techtips/cpp.../10min0300.asp
It explains allot, but still this doesn't fit in ?
http://expat.cvs.sourceforge.net/exp....h?view=markup
This is what is written on line 725 of expat.h ?
XMLPARSEAPI(const XML_Char *) XML_GetBase(XML_Parser parser);
Any idea what's XMLPARSEAPI(...) does ?
It's defined as a macro in the included file 'expat_external.h'
as

#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL

and in that file there's also a comment saying

XMLCALL - The calling convention to use for all calls across the
"library boundary." This will default to cdecl, and
try really hard to tell the compiler that's what we
want.

XMLIMPORT - Whatever magic is needed to note that a function is
to be imported from a dynamically loaded library
(.dll, .so, or .sl, depending on your platform).

So XMLCALL and XMLIMPORT are system-specific "magic" that for a start
you should considered to be defined to nothing, at least they aren't
anything that is related to standard C. So

XMLPARSEAPI(const XML_Char *) XML_GetBase(XML_Parser parser);

gets reduced to (at least if you want to understand the C part
of it, not the system-specific details)

const XML_Char * XML_GetBase(XML_Parser parser);

i.e. it declares a function that takes an argument of type 'XML_Parser'
and returns a pointer to a 'const XML_Char'.

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Jul 13 '07 #7
On Jul 13, 5:46 pm, j...@toerring.de (Jens Thoms Toerring) wrote:
gert <gert.cuyk...@gmail.comwrote:
i found the mother load of information about function pointer
http://gethelp.devx.com/techtips/cpp.../10min0300.asp
It explains allot, but still this doesn't fit in ?
http://expat.cvs.sourceforge.net/exp....h?view=markup
This is what is written on line 725 of expat.h ?
XMLPARSEAPI(const XML_Char *) XML_GetBase(XML_Parser parser);
Any idea what's XMLPARSEAPI(...) does ?

It's defined as a macro in the included file 'expat_external.h'
as

#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL

and in that file there's also a comment saying

XMLCALL - The calling convention to use for all calls across the
"library boundary." This will default to cdecl, and
try really hard to tell the compiler that's what we
want.

XMLIMPORT - Whatever magic is needed to note that a function is
to be imported from a dynamically loaded library
(.dll, .so, or .sl, depending on your platform).

So XMLCALL and XMLIMPORT are system-specific "magic" that for a start
you should considered to be defined to nothing, at least they aren't
anything that is related to standard C. So

XMLPARSEAPI(const XML_Char *) XML_GetBase(XML_Parser parser);

gets reduced to (at least if you want to understand the C part
of it, not the system-specific details)

const XML_Char * XML_GetBase(XML_Parser parser);

i.e. it declares a function that takes an argument of type 'XML_Parser'
and returns a pointer to a 'const XML_Char'.

Regards, Jens
--
\ Jens Thoms Toerring ___ j...@toerring.de
\__________________________ http://toerring.de
Thanks, that was exactly the c part i was looking for.
Will the next c compiler figure out all this system magic things by
him self ?

Jul 13 '07 #8
gert <ge**********@gmail.comwrote:
Will the next c compiler figure out all this system magic things by
him self ?
At least if it's one of the compilers and systems the authors
tested it on it should work. But if you try to compile that
program on a completely new system there's at least a chance
that it won't work and then you may have to delve into this
system-specific things to repair them (or ask the authors for
help).
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Jul 13 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Roger B. | last post by:
Hello, I am working on a personal interest project and have been racking my brain on this problem for about 5 hours total now, and tracking through old newsgroup posts but haven't figuried it...
761
by: Neo-LISPer | last post by:
Hey Recently, I researched using C++ for game programming and here is what I found: C++ game developers spend a lot of their time debugging corrupted memory. Few, if any, compilers offer...
8
by: markus | last post by:
Hi, As I been programming in C I have discovered more and more tools that really helps to speed up the development process when writing programs. Examples of such tools are cscope, cbrowser,...
2
by: Visually Seen # | last post by:
Hey everybody! I just want to discuss: what do people really use C# for? According to Microsoft, it was made for rapid software devolopment, and now everybody is on about XML, chat groups etc....
28
by: john_sips_tea | last post by:
Just tried Ruby over the past two days. I won't bore you with the reasons I didn't like it, however one thing really struck me about it that I think we (the Python community) can learn from. ...
8
by: pbd22 | last post by:
hi. i have spent the past week (i am afraid) trying to get the below script for uploading files via a hidden iframe to work. i have narrowed down my problem to the possibility that IE doesnt...
4
by: ICPooreMan | last post by:
I've got some code which works in firefox that's giving me fits in IE7 (maybe other versions too I haven't tested it). What I want to do is get the oncontextmenu attribute of something, change the...
4
by: Andre P.S Duarte | last post by:
I started reading the beginning Python book. It is intended for people who are starting out in the Python world. But it is really complicated, because he tries to explain, then after a bad...
3
by: a | last post by:
After several days struggling, I'm still unable to generate a string automatically *ONE by ONE*. I don't want to create a long array memorizing all the output strings and then traverse this array...
17
by: Chris M. Thomasson | last post by:
I use the following technique in all of my C++ projects; here is the example code with error checking omitted for brevity: _________________________________________________________________ /*...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.