Re: [RFA] Handle GPC specific name for main function

Joel Brobecker
2007-10-08T15:14:17Z

Hi Pierre,

Nothing like refreshing my confused knowledge of const-ification
in C while admiring the sunrise :). I'm an Ada programer more than
a C programer, so I hope I haven't contributed to your confusion.

> 1) Change of function type to "const char *"
> Chainging the return type of
> "pascal_main_name" to "const char *" seems fine for me,

And that's actually what we should do. I suggested "const char const *",
but in fact, I don't know what I was thinking, the latter is equivalent.
So just change the return type of function pascal_main_name to "const
char *".

You'll need to adjust the type of new_main_name in find_main_name to
"const char *" too. This is match the type returned by your function.
It is fine to leave ada_main_name return "char *" for now, I will
adjust it as a separate patch later

> but in the function "find_main_name", there is first a call to
> ada_main_name which is a "char *" function, and is now assigned to a
> "const char *", as you changed the type of "new_main_name" variable.

As said above, this should be fine. All we're doing when we say that
new_main_name is a "const char *" is that the contents of new_main_name
must not be changed. The compiler will check that for us. Assigning
a "char *" to new_main_name does not violate this restriction.

> + /* No known entry procedure found, the main program is probably
> + not compiled by GPC. */

This is fine as well.

--
Joel