NO

Author Topic: Problem with prototyping  (Read 4768 times)

post from old forum

  • Guest
Problem with prototyping
« on: September 14, 2004, 12:40:12 am »
Hi Pelle,

I've come across this problem several times: I will have the prototypes for all my functions, either in the main .c file or .h file, and the compiler will not find/recognize them.
I found a temporary fix was to change their position in the file.

Regards,
Isaac

-- Don't take offence - take a gate instead. --

post from old forum

  • Guest
Problem with prototyping
« Reply #1 on: September 14, 2004, 12:40:40 am »
Hello Isaac,

You mean you get compiler errors?
...or do you mean you can't see the functions in the treeview?

Do you have a small example? - this usually makes thing clearer.

Pelle

post from old forum

  • Guest
Problem with prototyping
« Reply #2 on: September 14, 2004, 12:41:11 am »
Sorry, I should have said this earlier:
Yes, I do get compiler warnings. For example:
I could have

int toupper(int c);

as a prototype function near the start of my *.c or *.h file. Then, I try to compile, and it gives me a warning along the line of "toupper() prototype not found", or something like that. I can generally fix it by putting my prototype down a line or two, which I think forces the compiler to find it. I don't know what exactly could be causing this - either a delayed save of the changes to the *.c file, or a corruption of information. Either way, the problem generally occurs after it has found the prototypes successfully, and then sometime later on a second or third build can no longer find them.'
I have found that I cannot reproduce the problem, and I am not sure whether it happens when I close down Pelles C and restart it, or if I just use the same window.

Regards,
Isaac

-- Don't take offence - take a gate instead. --

post from old forum

  • Guest
Problem with prototyping
« Reply #3 on: September 14, 2004, 12:41:43 am »
Hello Pelle,

I have found a similar problem, the tree in the IDE
did not show c-files after one file.
I succeeded to extract the code, that causes this.
If I replace
switch LOWORD(1){
by the outcommented line
switch ((WORD)(1)){
WinMain is shown.
If not, all functions after test1 are not shown in the tree.
Holger.


#include <windows.h>

void test1(void);

void test1(void)
{
//switch ((WORD)(1)){
switch LOWORD(1){
case 1:
;
}
}

int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
return 0;
}

Holger Buick

post from old forum

  • Guest
Problem with prototyping
« Reply #4 on: September 14, 2004, 12:42:22 am »
Hello Holger,

Thanks for the info! I think the problem, as usual, is with the browse information manager (pobr) - the browse information is used for listing functions in the project tree, as well as many other things.

The browse information manager will only scan files individually. For a C file, only the C file will be scanned for symbols and definitions, *not* all included files. This means that pobr will not see some definitions, and loose the context when parsing the file. This is most noticable when scanning Windows source code.

A better approach might be to let the compiler emit browse information, for each compiled file, into a special file and have another tool that will merge all special files into the browse information database. This will produce more accurate information, but the solution is more complex.

I will try to *fix* pobr for now - maybe changing to the above approach in a future version.

Pelle

post from old forum

  • Guest
Problem with prototyping
« Reply #5 on: September 14, 2004, 12:42:54 am »
Hello Pelle,

>I will try to *fix* pobr for now - maybe changing to
>the above approach in a future version.

Thanks!!

I was in hurry this morning and made a mistake:

It is not this:
---I have found a similar problem, the tree in the IDE
---did not show c-files after one file.
but this:
---I have found a similar problem, the tree in the IDE
---did not show c-functions after one function.
what I wanted to write, sorry.
(I had only one file in this example.)

Holger.