Xref: utzoo comp.sys.att:2927 unix-pc.general:520 Path: utzoo!mnetor!uunet!umbc3!alex From: alex@umbc3.UMD.EDU (Alex S. Crain) Newsgroups: comp.sys.att,unix-pc.general Subject: GNU cpp Message-ID: <929@umbc3.UMD.EDU> Date: 4 Apr 88 07:21:10 GMT Reply-To: alex@umbc3.UMD.EDU (Alex S. Crain) Organization: University of Maryland, Baltimore County Lines: 56 Keywords: "huk-huk Glorp!" goes /lib/ccom Summary: how to use it Hey Kids! Lots of people are touting the advantages of using GNU's C Preprocessor as opposed to the stock one. And there really are advantages, too, like the -M option (swiped from BSD, dumps make(1) dependency lines derived from the include files) and the larger hash tables (good for when you need to compile GNU software). There's a catch though. GNU cpp breaks the C compiler :-(. The SGS C compiler depends on a couple of idiosynchrosies (sp?) of the stock /lib/cpp, namely a) /lib/cpp never puts #line directives on consecutive lines. b) the first line out of /lib/cpp is a #line directive. If either if these conditions is not met, /lib/ccom forgets what file it is reading and generates bogus .s files (bogus file directives) so that sdb gets really confused and doesn't work right. GNU cpp gets b ok, but sometimes likes to put #line directives on consecutive lines. The fix for this is to modify the sprintf call near line 3438 in cccp.c to preceed the line directive with a \n, so that they will always be at least 1 line apart. (we can't add a \n to the end because that would put out phony line numbers). Unfortunately, that breaks condition a, because now the first character in the file is a \n. so now we have to add a flag so that we only preceed the line directive if its not the first line directive. Yuk! The result looks like: (somewhere in the file) int i_hate_att_braindamaged_software = 0; ---- ---- ---- if (i_hate_att_braindamaged_software == 0) { i_hate_att_braindamaged_software = 1; sprintf (line_cmd_buf, "# %d \"%s\"\n", ip->lineno, ip-fname); } else sprintf (line_cmd_buf, "\n# %d \"%s\"\n", ip->lineno, ip-fname); ---- ---- ---- Note that #line directives don't really use the "line" part. I'm going to go throw up now. -- :alex. nerwin!alex@umbc3.umd.edu alex@umbc3.umd.edu