error message program works ..

This is a discussion on error message program works .. within the C Programming forums, part of the General Programming Boards category; I have an error message "warning :incompatible impicit declaration of built-in function printf" which gave me a headache till I ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    54

    error message program works ..

    I have an error message "warning :incompatible impicit declaration of built-in function printf" which gave me a headache till I tried the program and it worked anyway.

    can anyone tell me what the message means or where to find out thanks.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by mad_muppet
    I have an error message "warning :incompatible impicit declaration of built-in function printf" which gave me a headache till I tried the program and it worked anyway.

    can anyone tell me what the message means or where to find out thanks.
    For the headache, take an aspirin, drink some water, sleep, and call me in the morning.

    Does your warning message also include or highlight the line number it's referring to?

    It's a witch to debug code that you can't see!

    Since the 'f' and 't' are typed by the same finger maybe you have a typo, or ?

    You have a built in function printf in stdio.h, and now you've got something else which also has the word or term "printf", in it, implicitly declared in your program.

    Search and destroy is your mission.

    And if you want help with code, or compiler complaints, please post the relevant parts inside code tags. My ability to read the minds of strangers is about as good as you'd guess it to be.

    Adak

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    54

    k here is the code

    its a work in progress ..
    Code:
    int comp( double r, double i )
    {
    	double rr; /* temporary real number variable */
    	double ii; /* temporary imaginary number variable */
    
    	int count = 1; /* how many times iterated before number excedes 			      terminal value */ 
    	int max = 3; /* maximum number of iterations before deciding 			            number belongs in the mandelbrot set */
    	do{
    		rr = r * r - abs ( i * i );
    		ii = 2 * r * i;
    		r = rr;
    		i = ii;
    		count++;
    	   }	
    	while ( count <= max && (( r + i ) < 4));
    
    	if ((( r + i) >= 4)){
    		printf(" out %d",count);
    		}
    	else{
    		printf(" in  ");
    		}
    }
    the warning is line 18 warning: incompatible impicit declaration of built -in function printf and the same warning again for line 21.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    54

    try that again eh doh

    Code:
    int comp( double r, double i )
    {
    	double rr; /* temporary real number variable */
    	double ii; /* temporary imaginary number variable */
    
    	int count = 1; /* how many times iterated before number excedes 			      terminal value */ 
    	int max = 3; /* maximum number of iterations before deciding 			            number belongs in the mandelbrot set */
    	do{
    		rr = r * r - abs ( i * i );
    		ii = 2 * r * i;
    		r += rr;
    		i += ii;
    		count++;
    	   }	
    	while ( count <= max && (( r + i ) < 4));
    
    	if ((( r + i) >= 4)){
    		printf(" out %d",count);
    		}
    	else{
    		printf(" in  ");
    		}
    }
    sorry for posting twice missed the += while reassigning r and i

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,588
    Well you could try
    #include <stdio.h>
    which is where printf() will be declared.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    54

    yeah thats in the main function

    so its there just not in the piece of code the warning gave as the problem area

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by mad_muppet
    so its there just not in the piece of code the warning gave as the problem area
    So did you include stdio.h or not?

    If that header file was included at the top of your program, and the stdio.h file is in the right directory and can be read ok by the OS, then I don't see why you would get this warning.

    It sounds like the header file was misspelled or couldn't be found in the directory where your compiler was looking.... but then why would it print your output ok?
    (do check your "directories" options)

    Perhaps it's smart enough to give you the warning, but continue looking for the header files in some other directories, and subsequently found it?

    That would be clever!

    Glad it all worked, anyway.

    Adak

  8. #8
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Or maybe our little friend was lazy to #include the stdlibs and the nice compiler caught it and put the stdlibs in anyway... gcc does that to some extent, for example.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  2. My program works but the numbers are not correct.
    By romeoz in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2003, 10:02 PM
  3. Replies: 3
    Last Post: 01-14-2003, 09:34 PM
  4. Enistine program
    By Mac_the vamp in forum C Programming
    Replies: 2
    Last Post: 11-11-2002, 09:56 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21