Mail Archives: pgcc/1998/07/13/14:17:36
On Sat, 11 Jul 1998, Vincent Diepeveen wrote:
> Hello,
>
> Forgive me my criticism, but after setting up linux i now try to compile
> diep for unix, and i get some weird results trying to compile with the
> standard gcc in redhat 5.1 (gcc --version gives: 2.7.2.3 ):
>
> first of all, why doesn't gcc have a predefined function like msvc++ have
> called:
> max() and min()?
>
(Assuming I am thinking about your max() and min() functions
correctly): Well, actually, it does. GCC has an even better implimentation
of these than vc++. The >? and <? operators for Max and Min respectively.
ie:
2 >? 4 = 4
2 <? 4 = 2
Be warned however, that these may only work in C++ (I'm not sure).
If you want it to be compatable w/ vc++, just add:
#ifdef __GNUC__
#define max(a, b) (a >? b)
#define min(a, b) (a <? b)
#endif
To the beginning of your code. Than you can use the min() and max()
functions the same way in both compilers and gcc will be able to optimize
for it.
> "the 'gets' function is dangerous and should not be used."
> What the #$$##$ does gcc think it's saying to me, am i not allowed to
> get a string from the keyboard, is there a bug in this function?
This is, just as it says, a dangerous function. All you have to
do is hit too many keys for the buffer given to gets() and BOOM! It isn't
that you're not allowed to do it, gcc is just politely recomending that
you don't.
--Insomnia
--Sleep is for the weak!
- Raw text -