> Doesn't #including a file in a .c file basically just tell the
> c-preprocessor to put that file's text in the current file?
Pretty much...but if you're using mysecondfunc in both segments, it's
considered "cleaner" to put the prototype (not function body) in a header
and include it.
> Since I am running into a problem with the 32k jump limit, just
> including the file as text from a .h file doesn't seem to me like it
> will solve my main problem.
Nope...you'll still need to put the function body in another .c file.
> I am converting a small app to a large app and that is why I am moving
> mysecondfunc to a .c file in a second segment.
> So...what should I be doing that I am not? Help!
> static Boolean mymainfunc(CharPtr myString)
> {
>
> extern Int mysecondfunc(CharPtr SomeString);
Move the "extern Int" out of the function body. You can put it either in a
header, or at the beginning of your .c file.
>> static Int mysecondfunc(CharPtr SomeString)
> You don't want "static" here.
...still applies. Put the prototype (same thing as above minus "extern") at
the top of your second .c file if you haven't put it in the header (you
might not need to have the prototype for C - not sure if that's a C++
thing).
So, you'll have one .c file that looks like:
// Prototype for function.
extern Int mysecondfunc(CharPtr SomeString);
static Boolean mymainfunc(CharPtr myString)
{
// Don't put the prototype here!
}
and another .c file that looks like:
// Prototype for function.
Int mysecondfunc(CharPtr SomeString);
// Function implementation.
Int mysecondfunc(CharPtr SomeString)
{
// Implementation.
}
Now, you can probably see why having the prototype in a header, which would
look like:
Int mysecondfun(CharPtr SomeString);
then in both .c:
#include "mysecondfun.h"
is cleaner.
My favorite C reference is the K&R (Kernighan and Ritchie) book, which you
can find here:
http://www.amazon.com/exec/obidos/ASIN/0131103628/o/qid=957808841/sr=8-1/ref
=aps_sr_b_1_1/103-9513835-4859838
This book is a very dense reference, and assumes you can already program in
another language and understand what things like conditionals and loops are.
For C++, get Stroustrup's book, which is quite good:
http://www.amazon.com/exec/obidos/ASIN/0201889544/ref=sim_books/103-9513835-
4859838
HTH,
Craig
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/