By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

error: expected ')' before '*' token -- What is this ?

P: n/a
I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1

my mfunc.c has on the line 42
-----------------------
.. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
SPF_response_t *spf_response = NULL;
SPF_result_t t;
SPF_request_set_ipv4_str( ecm_spf_request, ip );
SPF_request_set_helo_dom( ecm_spf_request, helo );
SPF_request_set_env_from( ecm_spf_request, sender );
SPF_request_query_mailfrom(ecm_spf_request, &spf_response);
t = SPF_response_result(spf_response);
SPF_response_free(spf_response);
return t;
}

.. . . . .


So what could be the error ?
Thanks
Ram

PS:
Note to Spammers: Go ahead , send me spam
ra*@netcore.co.in
http://ecm.netcore.co.in/spamtrap.html

Jul 31 '07 #1
Share this Question
Share on Google+
21 Replies


P: n/a
Ram Prasad <ra**********@gmail.comwrites:
I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1

my mfunc.c has on the line 42
-----------------------
. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
SPF_response_t *spf_response = NULL;
SPF_result_t t;
SPF_request_set_ipv4_str( ecm_spf_request, ip );
SPF_request_set_helo_dom( ecm_spf_request, helo );
SPF_request_set_env_from( ecm_spf_request, sender );
SPF_request_query_mailfrom(ecm_spf_request, &spf_response);
t = SPF_response_result(spf_response);
SPF_response_free(spf_response);
return t;
}

. . . . .


So what could be the error ?
Post all the code in that file and then "line 42" will be in context. It
isn't even apparent from above what IS on line 42. "----"? ". . . "? or
SPF_ ?
Jul 31 '07 #2

P: n/a
>
Post all the code in that file and then "line 42" will be in context. It
isn't even apparent from above what IS on line 42. "----"? ". . . "? or
SPF_ ?

The file is here
----
#include "mdef.h"
FILE* LOGFILE;


/*
* Opens file ( /var/log/milter.log ) for debug log
* any milter code can print to log file using addlog function
*/
void opendbglog(void){
LOGFILE=NULL;
LOGFILE=fopen(LOGFILENAME,"a");
if(LOGFILE==NULL){
fprintf(stderr,"Couldnot open logfile\n");
exit(1);
}
fprintf(LOGFILE,"opened logfile\n");
setvbuf(LOGFILE, (char *)NULL, _IONBF, 0);
}

/*
* Debug function
* using va_args for number of args
*
* usage addlog(number_of_arguments,arg1,arg2,arg3,arg4...)
*/

void addlog(int num_args, ... ) {
va_list ap;
if(LOGFILE == NULL ) return;
va_start(ap,num_args);
while(num_args--) fprintf(LOGFILE," %s ", va_arg(ap,char*));
va_end(ap);
fprintf(LOGFILE,"\n");
return;
}
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
SPF_response_t *spf_response = NULL;
SPF_result_t t;
SPF_request_set_ipv4_str( ecm_spf_request, ip );
SPF_request_set_helo_dom( ecm_spf_request, helo );
SPF_request_set_env_from( ecm_spf_request, sender );
SPF_request_query_mailfrom(ecm_spf_request, &spf_response);
t = SPF_response_result(spf_response);
SPF_response_free(spf_response);
return t;
}

Jul 31 '07 #3

P: n/a
Ram Prasad <ra**********@gmail.comwrites:
>>
Post all the code in that file and then "line 42" will be in context. It
isn't even apparent from above what IS on line 42. "----"? ". . . "? or
SPF_ ?


The file is here
----
*snip*

I loaded into a syntax hilited editor and saw no obvious syntax errors -
I cant see anything manually despite a quick scan, I guess there might
be troubles in mdef.h where I assume you are including <stdio.hamongst
other things. Without it one cant really tell.

Try commenting blocks out and then reinstating them to pinpoint the
error.
Jul 31 '07 #4

P: n/a
Ram Prasad wrote:

Please don't remove attribution lines.
[Richard wrote]
>Post all the code in that file and then "line 42" will be in context. It
isn't even apparent from above what IS on line 42. "----"? ". . . "? or
SPF_ ?


The file is here
----
#include "mdef.h"
FILE* LOGFILE;
It idiomatic in C to reserve all uppercase names for macros.
/*
* Opens file ( /var/log/milter.log ) for debug log
* any milter code can print to log file using addlog function
*/
void opendbglog(void){
LOGFILE=NULL;
LOGFILE=fopen(LOGFILENAME,"a");
if(LOGFILE==NULL){
fprintf(stderr,"Couldnot open logfile\n");
exit(1);
}
fprintf(LOGFILE,"opened logfile\n");
setvbuf(LOGFILE, (char *)NULL, _IONBF, 0);
The cast is not needed.
}

/*
* Debug function
* using va_args for number of args
* usage addlog(number_of_arguments,arg1,arg2,arg3,arg4...)
*/
void addlog(int num_args, ... ) {
va_list ap;
if(LOGFILE == NULL ) return;
va_start(ap,num_args);
while(num_args--) fprintf(LOGFILE," %s ", va_arg(ap,char*));
va_end(ap);
fprintf(LOGFILE,"\n");
return;
}

SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
SPF_response_t *spf_response = NULL;
SPF_result_t t;
SPF_request_set_ipv4_str( ecm_spf_request, ip );
SPF_request_set_helo_dom( ecm_spf_request, helo );
SPF_request_set_env_from( ecm_spf_request, sender );
SPF_request_query_mailfrom(ecm_spf_request, &spf_response);
t = SPF_response_result(spf_response);
SPF_response_free(spf_response);
return t;
}
We'll need to see the definitions for SPF_*_t types. I can't spot anything
amiss, just looking at the above code.

Jul 31 '07 #5

P: n/a
Ram Prasad wrote:
>Post all the code in that file and then "line 42" will be in context. It
isn't even apparent from above what IS on line 42. "----"? ". . . "? or
SPF_ ?


The file is here
[...]
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
Just a guess: Does the header file (which you didn't show)
declare a type named `SPF_request_t', or does it declare something
slightly different like `SPF_Request_t' or `SPF_request'? (Or
does it declare `struct SPF_request_t' but not `SPF_request_t'?)

--
Eric Sosman
es*****@ieee-dot-org.invalid
Jul 31 '07 #6

P: n/a
On Jul 31, 5:25 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
Ram Prasad wrote:
Post all the code in that file and then "line 42" will be in context. It
isn't even apparent from above what IS on line 42. "----"? ". . . "? or
SPF_ ?
The file is here
[...]
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {

Just a guess: Does the header file (which you didn't show)
declare a type named `SPF_request_t', or does it declare something
slightly different like `SPF_Request_t' or `SPF_request'? (Or
does it declare `struct SPF_request_t' but not `SPF_request_t'?)

--
Eric Sosman
esos...@ieee-dot-org.invalid
I am not much of a cprogrammer myself , ( been doing perl all this
while)
But I am willing to improve

Here you go, this is my mdef.h sorry for not posting all src code in
first place.
The spf header files come from standard libspf2-devel rpm

-------
#ifndef MDEF_H
#include "milterconfig.h"
#define MDEF_H 1
#include "milterconfig.h"

#include <time.h>
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <sysexits.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <syslog.h>
#include <regex.h/* Provides regular expression matching */
#include <strings.h/* String utillity functions */
#include <libmilter/mfapi.h>
#include <netinet/in.h>
# include <inttypes.h>
# include <string.h> /* strstr / strdup */
# include <sys/socket.h /* inet_ functions / structs */
# include <netinet/in.h /* inet_ functions / structs */
# include <arpa/inet.h> /* in_addr struct */
# include <unistd.h>
# include <spf.h>

#ifndef true
# define false 0
# define true 1
#endif /* ! true */

struct blist {
char *key;
};
typedef struct blist bl;
struct ecm_list_stru {
int count;
bl *list;
};

typedef struct ecm_list_stru ecml;

#define BLACKLIST_FILE "blacklist.txt"
/* Global functions */
void opendbglog(void);
void addlog(int num_args, ... ) ;
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request,char* ip, char*
helo, char* sender);
int compbl(const void *m1, const void *m2);
int init_ecml(ecml* el,char *filename);
int searchlist(ecml el,char *needle);
/* All definitions here */
#define LOGFILENAME "/var/log/milter.log"
#define MLOGLEVEL 5 /* level of error logs generation
0-5 */
#define MAXFROMSIZE 200
#define SAMPLE 1
/* some std structures */
struct mlfiPriv
{
#ifdef SAMPLE
char *mlfi_fname;
FILE *mlfi_fp;
#endif
#ifdef SPFCHECK
char mfrom[MAXFROMSIZE];
#endif
};

#define MLFIPRIV ((struct mlfiPriv *) smfi_getpriv(ctx))
#endif




Jul 31 '07 #7

P: n/a
On Jul 31, 6:31 am, Ram Prasad <ramprasad...@gmail.comwrote:
I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1

my mfunc.c has on the line 42
-----------------------
. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
SPF_response_t *spf_response = NULL;
SPF_result_t t;
SPF_request_set_ipv4_str( ecm_spf_request, ip );
SPF_request_set_helo_dom( ecm_spf_request, helo );
SPF_request_set_env_from( ecm_spf_request, sender );
SPF_request_query_mailfrom(ecm_spf_request, &spf_response);
t = SPF_response_result(spf_response);
SPF_response_free(spf_response);
return t;

}

. . . . .

So what could be the error ?
Well, the message says that the syntax error occurred
In file included from mfunc.c:1
which (in a later post) appears to be your
#include "mdef.h"

Otherwise, your code does not appear to contain any syntax errors that
would be detected and reported as
mfunc.c:42: error: expected ')' before '*' token
so I'm guessing that your mdef.h header has the syntax error.

HTH
--
Lew

Jul 31 '07 #8

P: n/a
Ram Prasad wrote:
On Jul 31, 5:25 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
>Ram Prasad wrote:
>Post all the code in that file and then "line 42" will be in context.
It isn't even apparent from above what IS on line 42. "----"? ". . .
"? or SPF_ ?
The file is here
[...]
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {

Just a guess: Does the header file (which you didn't show)
declare a type named `SPF_request_t', or does it declare something
slightly different like `SPF_Request_t' or `SPF_request'? (Or
does it declare `struct SPF_request_t' but not `SPF_request_t'?)
>
I am not much of a cprogrammer myself , ( been doing perl all this
while) But I am willing to improve

Here you go, this is my mdef.h sorry for not posting all src code in
first place. The spf header files come from standard libspf2-devel rpm
<snip header>

We still need the definitions for all the SPF_*_t types, particularly,
SPF_result_t and SPF_request_t.

Jul 31 '07 #9

P: n/a
Ram Prasad <ra**********@gmail.comwrites:
On Jul 31, 5:25 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
>Ram Prasad wrote:
>Post all the code in that file and then "line 42" will be in context. It
isn't even apparent from above what IS on line 42. "----"? ". . . "? or
SPF_ ?
The file is here
[...]
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {

Just a guess: Does the header file (which you didn't show)
declare a type named `SPF_request_t', or does it declare something
slightly different like `SPF_Request_t' or `SPF_request'? (Or
does it declare `struct SPF_request_t' but not `SPF_request_t'?)

--
Eric Sosman
esos...@ieee-dot-org.invalid

I am not much of a cprogrammer myself , ( been doing perl all this
while)
But I am willing to improve

Here you go, this is my mdef.h sorry for not posting all src code in
first place.
And you still haven't. There are other includes that people here
probably wont have. milterconfig.h for a start.

I suspect it would be quicker for you to comment/uncomment bit by bit to
find your error yourself.

btw, you include milterconfig.h twice for some reason.
Jul 31 '07 #10

P: n/a
>
We still need the definitions for all the SPF_*_t types, particularly,
SPF_result_t and SPF_request_t.
But these are standard header files
I got one file url here
http://csourcesearch.net/package/lib.../include/spf.h

Thanks
Ram

Jul 31 '07 #11

P: n/a
Ram Prasad wrote:
>>We still need the definitions for all the SPF_*_t types, particularly,
SPF_result_t and SPF_request_t.


But these are standard header files
No - they are part of a specific package. Nothing standard about them as
far as the C language goes.

I do wonder whether you'd get better help about developing with this
package by posting to a forum specifically for it, rather than a general
C newsgroup. Looking here <http://www.libspf2.org/support.htmlsuggests
some possibilities.
Jul 31 '07 #12

P: n/a
On Jul 31, 7:33 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
Ram Prasad wrote:
>We still need the definitions for all the SPF_*_t types, particularly,
SPF_result_t and SPF_request_t.
But these are standard header files

No - they are part of a specific package. Nothing standard about them as
far as the C language goes.

I do wonder whether you'd get better help about developing with this
package by posting to a forum specifically for it, rather than a general
C newsgroup. Looking here <http://www.libspf2.org/support.htmlsuggests
some possibilities.
But that is not a group of programmers. I simply wanted to know what
this error means
error: expected ')' before '*' token

Definetly it loooks like a syntax error , but there is absolutely no
error on that line
If I comment out the entire function and its declaration , then I dont
get this error. I just declare this function , without even defining
the code for it and gcc gives me this stupid error


Jul 31 '07 #13

P: n/a
Ram Prasad wrote:
On Jul 31, 7:33 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
>Ram Prasad wrote:
>>We still need the definitions for all the SPF_*_t types, particularly,
SPF_result_t and SPF_request_t.
But these are standard header files

No - they are part of a specific package. Nothing standard about them as
far as the C language goes.

I do wonder whether you'd get better help about developing with this
package by posting to a forum specifically for it, rather than a general
C newsgroup. Looking here <http://www.libspf2.org/support.htmlsuggests
some possibilities.

But that is not a group of programmers. I simply wanted to know what
this error means
error: expected ')' before '*' token

Definetly it loooks like a syntax error , but there is absolutely no
error on that line
If I comment out the entire function and its declaration , then I dont
get this error. I just declare this function , without even defining
the code for it and gcc gives me this stupid error
Find out the definition for all the SPF_*_types in the function declaration
and definition. What do they resolve into? Do you compile in ISO C
conforming mode or in someother mode? Is the code GNU C specific? If not,
try compiling with another compiler like Intel' or MSVC.

It's highly unlikely to a gcc bug. There must be some syntax error in your
code and header files. Try to compile a minimal program that still exhibits
the error. You can do that by leaving out stuff that are not absolutely
necessary for successful compilation or for exhibiting the error.

Jul 31 '07 #14

P: n/a
Ram Prasad wrote:
On Jul 31, 7:33 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
>>Ram Prasad wrote:
>>>>We still need the definitions for all the SPF_*_t types, particularly,
SPF_result_t and SPF_request_t.
>>>But these are standard header files

No - they are part of a specific package. Nothing standard about them as
far as the C language goes.

I do wonder whether you'd get better help about developing with this
package by posting to a forum specifically for it, rather than a general
C newsgroup. Looking here <http://www.libspf2.org/support.htmlsuggests
some possibilities.


But that is not a group of programmers.
It very like is, and it's probably a group of people who have developed
with this library and these header files. But if you don't want my
advice it hasn't cost you anything.
I simply wanted to know what
this error means
error: expected ')' before '*' token
It means the compiler expected something in parentheses to have been
completed, and the closing parenthesis supplied, before a '*' on line 42.
Definetly it loooks like a syntax error , but there is absolutely no
error on that line
Have you examined the code which the compiler is compiling?

I suggest you run the gcc compiler with whatever option will show you
the results of the precompiler - perhaps "-E". Examine that code and
work backwards.
Jul 31 '07 #15

P: n/a
On Tue, 31 Jul 2007 03:31:47 -0700, Ram Prasad
<ra**********@gmail.comwrote:
>I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1

my mfunc.c has on the line 42
-----------------------
. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
We still don't have enough information, but making some assumptions
and wild guesses, I suspect that the compiler is not recognizing
"SPF_request_t". Check it's definition, make sure the definition is
visible to the code with the error, and make sure you spelled
everything correctly. Do the same for all the strange types being
used.

--
Al Balmer
Sun City, AZ
Jul 31 '07 #16

P: n/a
In article <11**********************@d30g2000prg.googlegroups .com>,
Ram Prasad <ra**********@gmail.comwrote:
>gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
That is a very strange error message. If the files you have posted
are right, mfunc.c is not included in mfunc.c at line 1. Have you
omitted part of the error message? Or do you have a file mdef.h that
contains preprocessor output from some version of mfunc.c (perhaps
in /usr/local/include/spf2)? Check that the files all contain what
you expect them to.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jul 31 '07 #17

P: n/a
On Jul 31, 6:31 am, Ram Prasad <ramprasad...@gmail.comwrote:
I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1


I usually get this error when I mess up syntax (e.g. miss
a semicolon) or a header file has not been included properly.
Looks like things like SPF_request_t are not being recognized.
Make sure that the SPF.h (or whatever) files are included
and found (a message like "file SPF.h not found" is easy
to miss).

- William Hughes
>
my mfunc.c has on the line 42
-----------------------
. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
SPF_response_t *spf_response = NULL;
SPF_result_t t;
SPF_request_set_ipv4_str( ecm_spf_request, ip );
SPF_request_set_helo_dom( ecm_spf_request, helo );
SPF_request_set_env_from( ecm_spf_request, sender );
SPF_request_query_mailfrom(ecm_spf_request, &spf_response);
t = SPF_response_result(spf_response);
SPF_response_free(spf_response);
return t;

}

. . . . .

So what could be the error ?

Thanks
Ram

PS:
Note to Spammers: Go ahead , send me spam
r...@netcore.co.inhttp://ecm.netcore.co.in/spamtrap.html

Jul 31 '07 #18

P: n/a
Al Balmer wrote:
On Tue, 31 Jul 2007 03:31:47 -0700, Ram Prasad
<ra**********@gmail.comwrote:
>I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1

my mfunc.c has on the line 42
-----------------------
. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {

We still don't have enough information, but making some assumptions
and wild guesses, I suspect that the compiler is not recognizing
"SPF_request_t". Check it's definition, make sure the definition is
visible to the code with the error, and make sure you spelled
everything correctly. Do the same for all the strange types being
used.
I thought about the same problem but then, I saw that in that case it
wouldn't have recognized "SPF_result" either...

and canceled my post.

Jul 31 '07 #19

P: n/a
On Jul 31, 5:31 am, Ram Prasad <ramprasad...@gmail.comwrote:
I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1

my mfunc.c has on the line 42
-----------------------
. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
[snip]

Based on what you've posted here, SPF_request_t has not been properly
defined at this point; either you haven't #included the right header
file, or the header file has a syntax error in it.

Jul 31 '07 #20

P: n/a
Ram Prasad <ra**********@gmail.comwrites:
I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile

gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** [mfunc.o] Error 1

my mfunc.c has on the line 42
-----------------------
. . . . .
SPF_result_t spfcheck_s(SPF_request_t *ecm_spf_request, char* ip,
char* helo, char* sender) {
SPF_response_t *spf_response = NULL;
SPF_result_t t;
SPF_request_set_ipv4_str( ecm_spf_request, ip );
SPF_request_set_helo_dom( ecm_spf_request, helo );
SPF_request_set_env_from( ecm_spf_request, sender );
SPF_request_query_mailfrom(ecm_spf_request, &spf_response);
t = SPF_response_result(spf_response);
SPF_response_free(spf_response);
return t;
}
Typedef names are treated rather oddly in C. Within the compiler, a
typedef name, once it's declared, effectively becomes a keyword rather
than an ordinary identifier. This means that errors with typedef
names can cause bizarre-looking syntax error messages rather than the
"undeclared identifier" message you might expect.

Historical digression:
Early versions of C (before K&R1) didn't have 'typedef', and all
type names were defined by special syntax, not by single
identifiers. 'int', 'double', and so forth are all keywords,
arrays and pointers use special punctuators '[]' and '*',
structure types require a 'struct' keyword, and so forth. When
typedefs were added later on, they had to fit into that model,
which is why they behave so oddly. This can be surprising if
you're accustomed to other languages in which simple identifiers
commonly are used as type names.

For example, here's a small C translation unit with an obvious error:

typedef int my_type;
mytype x;

And here's what gcc has to say about it:

c.c:2: error: parse error before "x"
c.c:2: warning: data definition has no type or storage class

Since "mytype" hasn't been declared as a typedef, the compiler doesn't
even try to guess that it might be a type name, so it throws up its
hands and just fails to parse the declaration. (Possibly it could be
smarter about this, but apparently it isn't.)

I see no obvious errors in the code you posted *assuming* that
SPF_result_t and SPF_request_t have been declared as typedef names.
So, since the compiler is reporting a syntax error, it's likely that
either SPF_result_t or SPF_request_t is *not* declared as a typedef
name, or that neither is.

To test this, try temporarily adding a couple of dummy declarations
above your function definition:

SPF_result_t dummy1;
SPF_request_t dummy2;

and recompile. If I'm right, your compiler will report an equally
confusing syntax error message on one of those lines. Since syntax
errors can cause the compiler to quit trying to process the rest of
the file, try them one at a time. Once you've done that, your job is
to dig into all your nested include files and figure out *why* it's
not declared. Perhaps you haven't included the right header, or
you've misspelled the type name, or the typedef declaration is
excluded by a #if or #ifdef directive. Since the headers you're using
aren't part of the C standard, we can't help you with that.

Seeing the output of the preprocessor could be useful, but beware that
it's going to be very large, since all your headers and macros will be
expanded. gcc uses the "-E" option for this. If you know where your
compiler looks for header files, you might also try searching there
for "SPF_result_t" and/or "SPF_request_t".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 31 '07 #21

P: n/a
Ram Prasad wrote:
[...]
mfunc.c:42: error: expected ')' before '*' token
[...]

Life imitates art?

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Jul 31 '07 #22

This discussion thread is closed

Replies have been disabled for this discussion.