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

R

Ram Prasad

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
(e-mail address removed)
http://ecm.netcore.co.in/spamtrap.html
 
R

Richard

Ram Prasad said:
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_ ?
 
R

Ram Prasad

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;
}
 
R

Richard

Ram Prasad said:
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.h> amongst
other things. Without it one cant really tell.

Try commenting blocks out and then reinstating them to pinpoint the
error.
 
S

santosh

Ram Prasad wrote:

Please don't remove attribution lines.
[Richard wrote]
The file is here

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.
 
E

Eric Sosman

Ram said:
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'?)
 
R

Ram Prasad

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

-------
#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
 
L

Lew Pitcher

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
 
R

Richard

Ram Prasad said:
Ram said:
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.

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.
 
S

santosh

Ram said:
Ram said:
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.
 
M

Mark Bluemel

Ram said:
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.html> suggests
some possibilities.
 
R

Ram Prasad

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.html> suggests
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
 
S

santosh

Ram said:
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.
 
M

Mark Bluemel

Ram said:
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.
 
A

Al Balmer

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

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.
 
R

Richard Tobin

Ram Prasad said:
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
 
W

William Hughes

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
 
J

jacob navia

Al said:
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

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.
 
J

John Bode

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

[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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top