Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: GEOS-InfoBase-Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Sonntag, 20. November 2011, 22:15

Calling normal C routines and functions

Hi,

One of the things I don't understand is the following:

In the "Hello World" application described in the SDK, they create a normal C function:

void HelloDraw(GStateHandle gstate) { ... }

They call this function in the method that handles the MSG_META_EXPOSED message. And it seemingly works as expected.

Fair enough. But when I add my own function below GuessDraw, simply:

void GuessTest() { }

and call GuessTest() in my own message handler, I get a warning when running PMAKE: "Call to function 'GuessTest' with no prototype in function GuessProcessMETA_CONTENT_VIEW_WIN_OPENED". The code seems to run just fine though.

I don't see why I get a warnig with my method, while it never warns about HelloDraw, which does as far as I can see exactly the same.

Before I post code I was wondering if I was missing something obvious here...

Regards, Vincent

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »vvdleun« (20. November 2011, 22:57)


2

Sonntag, 20. November 2011, 22:56

RE: Calling normal C routines and functions

Hi!

Zitat

Original von vvdleun
void GuessTest { }


try void GuessTest(void) { } (in nearly all other C-/C++-dialects, the "void" is optional, however either Borland-C or GOC enforces it)
and keep in mind that you'll have to declare the function before using it (that's C/C++-standard, however in some other programming langauges the order in the file doesn't matter).

Hope this helps,
Jörg
d[ 0_O ]b

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »jpolzfuss« (20. November 2011, 22:56)


3

Sonntag, 20. November 2011, 23:03

Hi,

Thanks for the info, really didn't know about the required (void) parameter! I Will test it.

It's been quite a long time ago I programmed in C and I never really worked with a Borland C compiler before. Many years ago I taught myself C using Microsfot Quick C and later Power C by Mix Software. Later I (unfortunately) changed completely to Turbo Pascal.

Zitat

and keep in mind that you'll have to declare the function before using it (that's C/C++-standard, however in some other programming langauges the order in the file doesn't matter).


Yes, I am aware of that... that's why I'm puzzled I can't find a definition for GuessDraw in the Hello World app...

Thanks for your help!

Best regards,
Vincent

4

Montag, 21. November 2011, 09:22

Hi,


... and, you don't need a prototype like
void GuessTest(void);
if the implemetation of the function is placed "before" the call to that function happens. Therefore, there is no prototype in the Hello code. The compiler then knows the parameters allready.

Rainer


P.S. You should fix any "no prototype" Warning, in some rare cases this situation may be a reason for very strange runtime errors.
Es gibt 10 Arten von Menschen - die einen wissen was binär ist, die anderen nicht.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Rainer« (21. November 2011, 09:23)


5

Montag, 21. November 2011, 09:42

Hi,

Rainer, is that a Borland customization? I really seem to remember (but not a lot of my old C code survived, so could not check) I always defined every function in C, always. Perhaps my memory is wrong here though... or I had the wrong habit back then.

However, I fixed the warnings by adding void to the parameterlist. In theory I will not release anything that I can´t compile with warnings that I don´t understand.

Best regards,
Vincent

6

Montag, 21. November 2011, 15:22

Hi,

I dont know, if this a common or a Borland behavior. But it souds very reasonable to me.

Rainer

P.S to avoid translating errors ...
I did mean, if you write in the same file:

int MyFunction(void) {
Do some stuff...
return 4;
}

... some other code

y = MyFunction()

then the compiler knows the parameters.
Es gibt 10 Arten von Menschen - die einen wissen was binär ist, die anderen nicht.

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »Rainer« (21. November 2011, 15:23)


Thema bewerten