> > On Wed, Mar 15, 2000 at 08:03:48AM -0800, Rich Leggitt wrote: > > > > > But "%p" won't get rid of the warning; compiler does not inspect printf > > > format string. > > > > Actually it does inspect the format string. That's the reason for the warning. > > No way! You are saying that the compiler generates a warning based on the > contents of a constant string? How can this work? What if the string is > not constant, does the compiler ALWAYS generate the warning, or NEVER > generate the warning? > Yup. Many of the PIC C (or should I say "C-like") compilers don't impliment printf as a library function; It is implimented at the call site by the compiler. Therefore, it does indeed check for the proper use of the format specifiers, as well as the syntax, at compile time. For example, the CCS PCM "C-like" compiler does this. > And how does the compiler know to check for this, by the symbol 'printf'? > So if I define: > > char *magicprintf(const char *fmt,...); > The PCM compiler doesn't handle pointers to const data. You can impliment constant data tables like this: byte const byData[5]={'t','e','s','t',0}; and access members like this: byTestData=byData[2]; or even like this: byTestData=byData[nIndex]; but not like: pbyPointerToData= &byData[nIndex]; > this is treated differently than printf? And if I write my own printf > where "%p" means "pass-the-potatos", then what, the compiler chokes? > > I hate tools that get in the way. > Again, it is not "C", really... it is a language written with "C-like" syntax. This is explained in the PCM overview: "The compiler[s] have some limitations when compared to a more traditional C compiler. The hardware limitations make many traditional C compliers ineffective. As an example of the limitations, the compiler will not permit pointers to constant arrays. This is due to the separate code/data segments in the PIC hardware and the inability to treat ROM areas as data. [...]" (c) CCS, Inc. > > HI-TECH C: compiling the real world. > Thanks for the warning. > I think you might be a bit unhappy with these limitations. I was too.. for about the first hour. Then, when I bootstrapped an LCD display system inside of a few hours, I was extremely pleased. Yes, I am embarrassed that I specified this compiler (the price was right, and it handles floating point). But my job is to make money for my company.. not feel warm and fuzzy about how close my development tools adhere to an ANSI spec. :-) Respectfully yours, -d