Mail Archives: pgcc/1998/07/13/22:47:56
On Sat, Jul 11, 1998 at 11:28:40PM +0100, Vincent Diepeveen wrote:
> first of all, why doesn't gcc have a predefined function like msvc++ have
> called:
> max() and min()?
there aren't max() and min() functions in C, they are a proprietary msvc++
extension (you can look this up in msvc++'s manual)
You can define the MAX and MIN macros yourself, if you want to program in C,
rather than in Microsoft's proprietary dialect whose only purpose is to tie
you to the outdated windows platform.
Another solution might be to include sys/param.h on linux (with the same
caveats as above)
> int ReturnFloepWindow(char *sOut) {
> printf("%s\n",sOut);
> gets(sOut);
> return(true);
> }
>
> Now gcc gives next warning:
>
> "the 'gets' function is dangerous and should not be used."
1. thats not a gcc warning but a glibc warning (this distinction
is not very important)
2. its only a warning, you can ignore it if you want
3. its true, you should use fgets instead
the reason is that "gets" is a big security hole in many programs and a
nuisance causing mysterious coredumps in almost all programs, as "gets"
doesn't do any range-checking.
> 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?
you are safe, its not a bug per-se, its just a dangerous function
you can use but you shouldn't.
look at this that way: gcc (or glibc in this case), only tried to advise you
to write reliable programs. If you enable all warnings (with "-W -Wall"), it
will warn you bout numerous things, including things that are perfectly safe
in some environments, but broken in others, like this:
char latin1_to_codepage437[256];
char cp437, latin1;
cp437 = latin1_to_codepage437 [ latin1 ];
which will work on some machines but not on others.
-----==- |
----==-- _ |
---==---(_)__ __ ____ __ Marc Lehmann +--
--==---/ / _ \/ // /\ \/ / pcg AT goof DOT com |e|
-=====/_/_//_/\_,_/ /_/\_\ --+
The choice of a GNU generation |
|
- Raw text -