Hi folks,
I am trying to compile a simple program to play with mysql. But i am
running into single problems, but i guess easy to solve by too many of
the wizards here.
I am too paranoic when compiling my programs, so i activate all warnning
(at least i try) flags to gnu c compiler.
The problem occurs when type conversion: type conversion is automatic
when a functions takes a single pointer to const anything, but when
there is a double pointer to a const type and i pass double pointer to a
non const type i run into problem? Why in the later case conversion is
not automatic? the former is.
Here is the simple code (just to test):
#include <stdio.h>
int
t(const int *i)
{
printf("%d\n", *i);
return 0;
}
void
c(const char **reg)
{
while (*reg)
printf("%s\n", *reg++);
}
int
main(int argc, char *argv[])
{
int i;
char *reg[] = {
"Gustavo",
"Vieira",
"Goncalves",
"Coelho", "Rios", NULL};
i = 10;
(void) t(&i);
c(reg);
return 0;
}
But when compiling:
grios@etosha$ cc -ansi -pedantic -Wconversion -Wall -Werror t.c
cc1: warnings being treated as errors
t.c: In function `main':
t.c:30: warning: passing arg 1 of `c' from incompatible pointer type
grios@etosha$
Why there is no problem when i pass a int * to as an argument to a
function that requires a const int * but when the argument is a double
pointer to a const it complains if i pass a double pointer to a non
const type. This warnnings always happen even if the argument
requirement is of type
const [int|float|double|any_thing] ** and the value passed is
[int|float|double|any_thing] **. Why automatic conversion does not take
place here too ?
Thanks a lot for your time and cooperation.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
C program warnning (Just a test i try to understand C in order to build my mysql client program)
Gustavo Vieira Goncalves Coelho Rios Wed, 14 Feb 2001 04:00:30 -0800
- Re: [OT] C program warnning (Just a t... Gustavo Vieira Goncalves Coelho Rios
- Re: [OT] C program warnning (Jus... Benjamin Pflugmann
