proto.h error?

Dear all,
I’m having troubles when compiling a project as I get several error messages
referring to a line in the proto.h file containging the prototype:
void start_password_dialog( ACCESS_LEVEL required level , void
(*extra_function )( Pt_Widget_t *) , Pt_Widget_t *widget );

The compiler errors are:
proto.h(50): Error! E1009: Expecting ‘,’ but found ‘required_level’
proto.h(50): Error! E1094: Function cannot return a function
proto.h(50): Error! E1009: Expecting ‘,’ but found ‘*’
proto.h(50): Error! E1129: Type does not agree with previous definition of
‘Pt_Widget_t’
proto.h(50): Error! E1009: Expecting ‘;’ but found ‘)’

Apparently the compiler doesn’t think the prototype is correct, however PhAB
itself has generated it!
I seem to have ruled out syntax errors/double prototyping.

Could this be a configuration problem in PhAB?

The project is build in QNX 4.25 / Photon V1.14 using Watcom compiler V10.6
to compile source files. Files/prototypes etc have been generated within
PhAB while the project is compiled from a command line.

I would very much appreciate if anyone would give me a hint.

Cheers,
Lars

Lars Skade <larsskade@telefonica.net> wrote:

I’m having troubles when compiling a project as I get several error messages
referring to a line in the proto.h file containging the prototype:
void start_password_dialog( ACCESS_LEVEL required level , void
(*extra_function )( Pt_Widget_t *) , Pt_Widget_t *widget );

The compiler errors are:
proto.h(50): Error! E1009: Expecting ‘,’ but found ‘required_level’

It looks like the compiler doesn’t know that ACCESS_LEVEL is a type.
Make sure that it’s spelled correctly and that your application’s
“global header” defines it (either directly or by including the
appropriate header).

Apparently the compiler doesn’t think the prototype is correct, however PhAB
itself has generated it!

It’s not really PhAB: PhAB just runs a program (called approto) that
scans all your source files and extract prototypes from the code. If
your code contains syntax errors or unusual preprocessor tricks, the
approto program sometimes makes a mistake and generates a proto.h that
contains even more syntax errors and produces compile errors even after
you fix your code.

(My personal preference is to disable the scanning altogether – there’s
a “Generate empty proto.h” button in the F2 dialog that does that.
PhAB will still generate prototypes for any callbacks it knows about,
but you’ll have to take care about any other functions yourself.)

Thanks a lot for the reply however I’m afraid it doesn’t help me.
ACCESS_LEVEL has already been defined in the globals.h file as…
typedef enum
{
AAA,
BBB
} ACCESS_LEVEL;
and spelling is ok.

As for the “Generate empty proto.h” I would rather not start using this as
it would require mayor rework of the application.
What I’m trying to do is only a minor modification!

Best regards,
Lars

“Wojtek Lerch” <wojtek_l@yahoo.ca> escribió en el mensaje
news:bu13qh$5se$1@nntp.qnx.com

Lars Skade <> larsskade@telefonica.net> > wrote:
I’m having troubles when compiling a project as I get several error
messages
referring to a line in the proto.h file containging the prototype:
void start_password_dialog( ACCESS_LEVEL required level , void
(*extra_function )( Pt_Widget_t *) , Pt_Widget_t *widget );

The compiler errors are:
proto.h(50): Error! E1009: Expecting ‘,’ but found ‘required_level’

It looks like the compiler doesn’t know that ACCESS_LEVEL is a type.
Make sure that it’s spelled correctly and that your application’s
“global header” defines it (either directly or by including the
appropriate header).

Apparently the compiler doesn’t think the prototype is correct, however
PhAB
itself has generated it!

It’s not really PhAB: PhAB just runs a program (called approto) that
scans all your source files and extract prototypes from the code. If
your code contains syntax errors or unusual preprocessor tricks, the
approto program sometimes makes a mistake and generates a proto.h that
contains even more syntax errors and produces compile errors even after
you fix your code.

(My personal preference is to disable the scanning altogether – there’s
a “Generate empty proto.h” button in the F2 dialog that does that.
PhAB will still generate prototypes for any callbacks it knows about,
but you’ll have to take care about any other functions yourself.)

Lars Skade <larsskade@telefonica.net> wrote:

Thanks a lot for the reply however I’m afraid it doesn’t help me.
ACCESS_LEVEL has already been defined in the globals.h file as…
typedef enum
{
AAA,
BBB
} ACCESS_LEVEL;
and spelling is ok.

Are you getting this error when compiling abmain.c, or is it coming from
some of your C files? If it’s abmain.c, this means that globals.h is not
set to be the “global header” in PhAB. If it’s one of your files, it
means that it’s missing the ‘#include “globals.h”’ line and you need to
add it by hand.

I get the error when compiling one of my c files.
The globals.h is definitely included even though it’s included through
another header file that has included it. Trying to explicitly include it in
the c file gives me several compiler error of stuff that has been included
twice.

Interesting enough I have found a way to work around the problem: I first
open up the proto.h and comment out the prototype for the function that
produces the errors. I then compile the project with no errors. Then reopen
the proto.h and remove the commenting out and I’m then able to recompile the
project without any errors.
This of course is unacceptable and that’s why I’m desperate to sort out the
problem!

Cheers,

Lars


“Wojtek Lerch” <wojtek_l@yahoo.ca> escribió en el mensaje
news:bu3ofb$2gg$1@nntp.qnx.com

Lars Skade <> larsskade@telefonica.net> > wrote:
Thanks a lot for the reply however I’m afraid it doesn’t help me.
ACCESS_LEVEL has already been defined in the globals.h file as…
typedef enum
{
AAA,
BBB
} ACCESS_LEVEL;
and spelling is ok.

Are you getting this error when compiling abmain.c, or is it coming from
some of your C files? If it’s abmain.c, this means that globals.h is not
set to be the “global header” in PhAB. If it’s one of your files, it
means that it’s missing the ‘#include “globals.h”’ line and you need to
add it by hand.

Lars Skade <larsskade@telefonica.net> wrote:

I get the error when compiling one of my c files.
The globals.h is definitely included even though it’s included through
another header file that has included it. Trying to explicitly include it in
the c file gives me several compiler error of stuff that has been included
twice.

Is there a chance that you’re including proto.h before globals.h? Have
you tried to run the code through the preprocessor and see whether
ACCESS_LEVEL indeed is defined before the prototype?

Anyway, this is not really a PhAB problem. It’s about how you design
your headers and include them in the proper order.

You have a header containing prototypes for all the functions in all
your source files. For this header to compile, you need to make sure
that all the types that are used in the prototypes are defined before
you include the header. How you do that in your source files is up to
you. How you do it in PhAB’s abmain.c is simple in principle: you just
need to put all the necessary stuff in the “global header”, and abmain.c
will include it before including proto.h.

Interesting enough I have found a way to work around the problem: I first
open up the proto.h and comment out the prototype for the function that
produces the errors. I then compile the project with no errors. Then reopen
the proto.h and remove the commenting out and I’m then able to recompile the
project without any errors.

By “recompile”, do you really mean recompile? :wink:

If you just type make after a successfull build, you’re just relinking
but not recompiling. PhAB Makefiles don’t normally have a dependency on
proto.h.

This is how I solved a similar problem. In the default directory, in the
Makefile, I modified the target for “proto” thus:

Prototype Generation

proto:
echo “#include <file1.h>” >proto.h
echo “#include “file2.h”” >>proto.h
approto -p $(ABSRC) $(MYSRC) >>proto.h

In essence, this makes sure that proto.h has includes for file1.h, file2.h,
etc., at the beginning of the file, where these files have the definitions
necessary for the problem prototypes. Works like a charm. You can use the
classic “#ifndef” way to make sure that file1.h et al are only included
once.

“Wojtek Lerch” <wojtek_l@yahoo.ca> wrote in message
news:bu6dov$ga8$1@nntp.qnx.com

Lars Skade <> larsskade@telefonica.net> > wrote:
I get the error when compiling one of my c files.
The globals.h is definitely included even though it’s included through
another header file that has included it. Trying to explicitly include
it in
the c file gives me several compiler error of stuff that has been
included
twice.

Is there a chance that you’re including proto.h before globals.h? Have
you tried to run the code through the preprocessor and see whether
ACCESS_LEVEL indeed is defined before the prototype?

Anyway, this is not really a PhAB problem. It’s about how you design
your headers and include them in the proper order.

You have a header containing prototypes for all the functions in all
your source files. For this header to compile, you need to make sure
that all the types that are used in the prototypes are defined before
you include the header. How you do that in your source files is up to
you. How you do it in PhAB’s abmain.c is simple in principle: you just
need to put all the necessary stuff in the “global header”, and abmain.c
will include it before including proto.h.

Interesting enough I have found a way to work around the problem: I
first
open up the proto.h and comment out the prototype for the function that
produces the errors. I then compile the project with no errors. Then
reopen
the proto.h and remove the commenting out and I’m then able to recompile
the
project without any errors.

By “recompile”, do you really mean recompile? > :wink:

If you just type make after a successfull build, you’re just relinking
but not recompiling. PhAB Makefiles don’t normally have a dependency on
proto.h.

Personally, I have to admit I find this rather ugly… Does it have any
advantages compared to putting those two #include lines in a “global”
header, and including that header just before proto.h in all your C
files?

Kevin Miller <kevin.miller@transcore.com> wrote:

This is how I solved a similar problem. In the default directory, in the
Makefile, I modified the target for “proto” thus:

Prototype Generation

proto:
echo “#include <file1.h>” >proto.h
echo “#include “file2.h”” >>proto.h
approto -p $(ABSRC) $(MYSRC) >>proto.h

In essence, this makes sure that proto.h has includes for file1.h, file2.h,
etc., at the beginning of the file, where these files have the definitions
necessary for the problem prototypes. Works like a charm. You can use the
classic “#ifndef” way to make sure that file1.h et al are only included
once.

Problem solved!

Thanks a lot for your help. It indeed was just because of the order I had
included the header files!

Best regards,
Lars

“Wojtek Lerch” <wojtek_l@yahoo.ca> escribió en el mensaje
news:bu6loe$n9q$1@nntp.qnx.com

Personally, I have to admit I find this rather ugly… Does it have any
advantages compared to putting those two #include lines in a “global”
header, and including that header just before proto.h in all your C
files?

Kevin Miller <> kevin.miller@transcore.com> > wrote:
This is how I solved a similar problem. In the default directory, in the
Makefile, I modified the target for “proto” thus:

Prototype Generation

proto:
echo “#include <file1.h>” >proto.h
echo “#include “file2.h”” >>proto.h
approto -p $(ABSRC) $(MYSRC) >>proto.h

In essence, this makes sure that proto.h has includes for file1.h,
file2.h,
etc., at the beginning of the file, where these files have the
definitions
necessary for the problem prototypes. Works like a charm. You can use
the
classic “#ifndef” way to make sure that file1.h et al are only included
once.