Title: Re: Sample Metrowerk Project with multiple .c and .h f
At 5:47 PM -0500 12/16/99, Rubin, Dan wrote:
I have written a small palm app that is getting large.  I would like to
split it up into functional .c files and their associated headers.  I cannot
seem to get this to work in the Metrowerks IDE.  I keep getting "precompiled
header" errors when I include <Pilot.h> in multiple files and other erros
(of course) when I take it out

The Memo Pad example has several source files. You need to include <Pilot.h> at the beginning of each of your .c files (or in your prefix file - see below). Don't include it in any of your .h files. To prevent your own .h files from being included more than once, use this format for your .h files:

#ifndef __FOO_H__
#define __FOO_H__

... your entire .h file goes here...

#endif

Or in CodeWarrior, just put:

#pragma once

at the top of each .h file.

If you want better browser coloring and such, and are willing to put up with somewhat slower compiles, I recommend turning off pre-compiled headers by adding:

#define PILOT_PRECOMPILED_HEADERS_OFF

just before you include <Pilot.h> at the top of each of your .c files (or in your prefix file).

CodeWarrior lets you specify a prefix file which is implicitly included at the start of each of your .c files. The prefix file is specified in the C/C++ Language Settings panel of the target settings. If you have separate targets for debug and release builds, you can use separate prefix files.

Reply via email to