473,395 Members | 1,413 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,395 software developers and data experts.

Interpreting some code

I came across a construction in some code I was reading that I have
never seen before and hope that someone could tell me how to
interpret this:

int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
const char *,
const char *,
const char **);

It looks like a function declaration to me but the "[XML_N_LITERAL_TYPES]"
part throws me off.

Regards
Chris Saunders
ch************@sympatico.ca
Nov 13 '05 #1
5 1882
Chris Saunders <ch************@sympatico.ca> scribbled the following:
I came across a construction in some code I was reading that I have
never seen before and hope that someone could tell me how to
interpret this: int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
const char *,
const char *,
const char **); It looks like a function declaration to me but the "[XML_N_LITERAL_TYPES]"
part throws me off.


It's declaring an array of pointers to function, not declaring a
function. There are XML_N_LITERAL_TYPES pointers in that array, and
they each point to a function returning int and accepting parameters
(const ENCODING *, const char *, const char *, const char **).

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"I wish someone we knew would die so we could leave them flowers."
- A 6-year-old girl, upon seeing flowers in a cemetery
Nov 13 '05 #2
"Chris Saunders" <ch************@sympatico.ca> writes:
int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
const char *,
const char *,
const char **);


Array of pointers to functions returning int.
--
"Large amounts of money tend to quench any scruples I might be having."
-- Stephan Wilms
Nov 13 '05 #3
Chris Saunders wrote:
I came across a construction in some code I was reading that I have
never seen before and hope that someone could tell me how to
interpret this:

int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
const char *,
const char *,
const char **);

It looks like a function declaration to me but the "[XML_N_LITERAL_TYPES]"
part throws me off.


That's an array with XML_N_LITERAL_TYPES items of pointers to function
taking (const ENC...) as arguments and returning an int.
Tobias.

--
unix http://www.faqs.org/faqs/by-newsgrou...rogrammer.html
clc http://www.eskimo.com/~scs/C-faq/top.html
fclc (french): http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #4
My thanks to all who responded.

Regards
Chris Saunders
ch************@sympatico.ca

"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@pfaff.Stanford.EDU...
"Chris Saunders" <ch************@sympatico.ca> writes:
int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
const char *,
const char *,
const char **);


Array of pointers to functions returning int.
--
"Large amounts of money tend to quench any scruples I might be having."
-- Stephan Wilms

Nov 13 '05 #5
In <KB******************@news20.bellglobal.com> "Chris Saunders" <ch************@sympatico.ca> writes:
I came across a construction in some code I was reading that I have
never seen before and hope that someone could tell me how to
interpret this:

int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
const char *,
const char *,
const char **);

It looks like a function declaration to me but the "[XML_N_LITERAL_TYPES]"
part throws me off.


Then remove it and you're left with:

int (*literalScanners)(const ENCODING *, const char * ...);

which can be easily recognised as the declaration of a pointer to
function. So, what do we have when we put "[XML_N_LITERAL_TYPES]" back
in? An array of pointers to functions.

Note that such declarations need not be that cryptical. A single typedef
can do wonders:

typedef int func_t(const ENCODING *, const char *, const char * ...);
func_t *literalScanners[XML_N_LITERAL_TYPES];

Now, it's glaringly obvious that literalScanners is an array of pointers.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #6

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

Similar topics

10
by: r6uji7 | last post by:
hello, i am new to PHP programming and wondered if u could help. lets say i have the following files: 1. error.php: that is routed to for all errors. this page should display proper and...
1
by: Thomas Parslow | last post by:
Hi, I'm using an ASPTemplate class (the one from asptemplate.sourceforge.net) to produce WAP and HTML verions of the same pages. It seemed to me that it would be very usefull to have the...
3
by: Roger Sherman | last post by:
I'm using CYGWIN g++. I'm having trouble making an API call the WindowFromPoint function. Here is my code. FILE: t.cc #include <windows.h> int main () { POINT p;
3
by: Chris Saunders | last post by:
I am attempting to write and interface from another language to some C code. I am having some difficulty interpreting a declaration. int (*SSL_CTX_get_verify_callback(SSL_CTX...
4
by: zolli | last post by:
Hi, This question is about a piece of Linux kernel code, but is in fact a C language question. I was looking throught some memory map init code and ran into the following: p = mem_map +...
3
by: Chris Saunders | last post by:
Hope this question is appropriate here. I'm writing an interface to some C code for the language Eiffel. I have come across this macro and am having difficuly interpreting what it returns: ...
0
by: holysmokes99 | last post by:
I have a VB.Net (1.1) that uses SQL-DMO via COM Interop to create a linked server. The code throws an exception, as it should, when the linked server I am trying to create already exists on the...
2
by: mfsiddiq | last post by:
Hi I want to know if there is any way a string can be interpreted as function name.I need this to call functions dynamically.Below is a code snippet which works fine if the function is in the same...
2
luke14free
by: luke14free | last post by:
Hello, I'm writing a live chat in php and ajax (prototype.js). My problem is that, when the periodical updater gets chat text from an external php page, under IE \n\r are not recognized ...
6
by: mikemtnbikes | last post by:
Hello, I'm a biologist who does a fair amount of hack programming. I'm not really formally trained so perhaps this question is a bit basic. My problem is that I'm trying to understand some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.