9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] trouble with include order using c compiler with ansi preprocessor
@ 2007-06-10 16:35 Kim Shrier
  2007-06-10 17:27 ` [9fans] trouble with include order using c compiler with ansi Charles Forsyth
  2007-06-10 18:10 ` [9fans] trouble with include order using c compiler with ansi preprocessor Martin Neubauer
  0 siblings, 2 replies; 13+ messages in thread
From: Kim Shrier @ 2007-06-10 16:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

I am exploring the tools on Plan 9 and I am having a problem
getting the correct files to be included.  My test setup is
that I have a directory with C source and headers.  In a sub-
directory, I have the plan 9 mkfile and a customized version
of one of the header files.  I would like the C compiler to
find my customized version of the header instead of the one
in the original source directory.

The desired results of running my test is:
cpu% cd source/plan9
cpu% mk
cpu% ./main
MSG = this is from plan9/inc1.h
MSG2 = this is from inc2.h
cpu%

However, everything I have tried results in:
cpu% ./main
MSG = this is from inc1.h
MSG2 = this is from inc2.h
cpu%

The files I am using for the test are:

source/
     inc1.h
     inc2.h
     main.c
     plan9/
         inc1.h
         mkfile


inc1.h:
#define MSG "this is from inc1.h"

inc2.h:
#define MSG2 "this is from inc2.h"

main.c:
#include <u.h>
#include <libc.h>

#include "inc1.h"
#include "inc2.h"

void
main (int argc, char *argv[])
{
	print ("MSG = %s\n", MSG);
	print ("MSG2 = %s\n", MSG2);

	exits (0);
}


plan9/inc1.h:
#define MSG "this is from plan9/inc1.h"

plan9/mkfile
</$objtype/mkfile

CFLAGS=-p -N -.
LDFLAGS=

main: main.$O
	$LD $LDFLAGS -o main main.$O

main.$O: ../main.c
	$CC $CFLAGS ../main.c

clean:V:
	rm -f main main.$O


I have tried many combinations of -N, -., -I., -I.., and nothing
seems to work.  I would expect that the above CFLAGS definition
would cause the compiler to not find either inc1.h or inc2.h.
However, even with CFLAGS=-p -N -., it finds both the header files
in source.

If I do not use the ANSI preprocessor, setting CFLAGS=-. -I. -I..
works.

I am running on a Plan 9 cpu server that I updated on May 18.

Any enlightenment would be appreciated.

Kim


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-06-11  7:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-10 16:35 [9fans] trouble with include order using c compiler with ansi preprocessor Kim Shrier
2007-06-10 17:27 ` [9fans] trouble with include order using c compiler with ansi Charles Forsyth
2007-06-10 17:44   ` Kim Shrier
2007-06-10 18:10 ` [9fans] trouble with include order using c compiler with ansi preprocessor Martin Neubauer
2007-06-10 19:24   ` Kim Shrier
2007-06-10 19:26   ` erik quanstrom
2007-06-10 20:07     ` Russ Cox
2007-06-10 20:44     ` Kim Shrier
2007-06-10 22:02       ` Uriel
2007-06-10 22:47         ` Kim Shrier
2007-06-11  0:10           ` Kris Maglione
2007-06-11  1:41             ` Kim Shrier
2007-06-11  7:51       ` Steve Simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).