Related articles |
---|
Inter-module type checking for C (was: A lesson for ...) rfg@ncd.com (1992-06-19) |
Re: Inter-module type checking for C (was: A lesson for ...) rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) (1992-06-22) |
Re: Inter-module type checking for C (was: A lesson for ...) rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) (1992-06-22) |
Re: Inter-module type checking for C (was: A lesson for ...) ian@airs.com (1992-06-22) |
Newsgroups: | comp.compilers |
From: | Raul Deluth Miller-Rockwell <rockwell@socrates.umd.edu> |
Keywords: | C, lint |
Organization: | Compilers Central |
References: | <19920609091040SEB1525@MVS.draper.com> 92-06-103 |
Date: | Mon, 22 Jun 1992 13:33:01 GMT |
I received an email message which indicated my last post was somewhat
less than clear. Reply follows.
Me (orig post):
Basically, you have one .h file which defines a few macros,
includes all the .c file, then undefs/redefs the macros. Your
macros are set up to give extern declarations the first time around
and complete declarations afterwards.
email:
Q: have you ever actually done this for a large system
involving say, 200+ .c files and 50+ .h files? If so
then I'm curious -- how did you organize things?
reply:
No, I'm not that patient. When the program gets that big I switch
languages [usually, to APL]. Occasionally, APL won't be fast enough,
which means that I need a new primitive [to deal with the essence of
that one thing that's eating 80% of the time].
I have tried stuff like
----------------
foo.h:
#ifndef FOO_H
#define FOO_H
#include "foo.c"
#define CODE
#endif FOO_H
foo.c:
#include "foo.h"
int foo(... foo declaration ...)
#ifdef CODE
{
}
#else
;
#endif CODE
----------------
I do somthing more like foo.c:
#include "headers.h"
...
EXPORTF int p_line(char * string, int * position, symtab_t * symtab)
INTERNALF({
/* ... blah blay */
if ( ) { ...
})
and so on.
in headers.h I've got
#define EXPORTF extern
#define INTERNALF(x) ;
#include "foo.c"
#include "bar.c"
#include "bax.c"
...
#undef EXPORTF
#define EXPORTF
#undef INTERNALF
#define INTERNALF(x) x
And, for those cases which I can't generalize in terms of macros I'll
define something like
#define EMIT_CODE
Ok, this is a simplification -- I'll often want macros for static
declarations, and various forms of data declarations might want their
own macros. Also, I usually define EXPORTF as taking an argument, but
I can't think why.
--
Raul Deluth Miller-Rockwell <rockwell@socrates.umd.edu>
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.