CompuServe Messages

Size_t existence

    08-Aug-93 16:06:02
Sb: #8311-Size_t existence
Fm: Joe Sewell 74136,360
To: Syndesis 76004,1763
–> Pragmas may be "ANSI compliant", but they're certainly implementation dependent. <– No argument there at all. (Which means that an "ANSI C" program isn't necessarily a portable C program.) –> It appears to me that you're defending the way Think C did this, and I'm arguing that they leaned on a pragma when 3-4 other compilers all "happen" to do it the same way. So far, your argument says "They did it the right way because that's the way they did it." Please, tell me your argument is a bit stronger or even plausible, such as "they did it to gain a nine point five percent speed increase in the average compile." <– Actually, I'm arguing against the notion that #pragma once is 100% bad and should be removed, which is what I'm reading in several messages here. There IS an advantage to #pragma once, in that using it incurs no file I/O after you've #included it the first time; the disadvantage is that you cannot add it to the list of headers for a file or project if it's already in MacHeaders (as Dave Ely pointed out). How much speed advantage #pragma once gives you really depends on the size & efficiency of the disk cache, if any, and whether the file pieces are cached or not; I would guess (since I have no hard numbers) that #pragma once is always more efficient than opening the file, reading it, bypassing the whole thing (requiring the whole file to be read & cached again, which could flush something ELSE out of the cache), and basically throwing it away. As for the size_t thing, that IS something that's difficult in general, although some compilers let you do it directly. As Phil Shapiro pointed out (trying to get us back on track, I see now 🙂 ), there's no standard way of doing that, but there ARE ways you can do it and not violate the standard. It's just not portable (which says that standard != portable). You could always just #include the file defining size_t again, to make sure; at best (with THINK C & #pragma once) it'll be a no-op if it was included earlier, at worst (without #pragma once or #ifndef/#define/#endif), you'll get a duplicate definition. Joe