conflicting types for...

This is a discussion on conflicting types for... within the C Programming forums, part of the General Programming Boards category; hi ! (thanx for the hlp the previous time) I'm trying to call a function from another function: Code: void ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    6

    Question conflicting types for...

    hi !
    (thanx for the hlp the previous time)

    I'm trying to call a function from another function:

    Code:
    void movement(int num_discs) {
         double i=basic_data[0];
         int j,k;
         .......
         .......
         wall_collision(num_discs);
         .....
    }
    
    void wall_collision(int num_discs) {
         double smallx,smally,bigx,bigy;
         int k;
         if(.........
    }
    
    main() {
           int num_discs /* it is pre-defind */;
           movement(num_discs);
    }
    the error I get:
    "conflicting types for 'wall_collision' "
    and:
    "previous implicit declaration of 'wall_collision' was here "
    (points to this line:
    Code:
    wall_collision(num_discs);
    )

    what could it be ?
    can't I declare double/int... variables inside a function that gets an int value for example ?

    -------------------------------------------

    and... - what could the problem be:

    Code:
    if(disc[k].r=fabs(disc[k].x-basic_data[6]) || disc[k].r=fabs(disc[k].x-basic_data[7])) {............
    I get: "invalid lvalue in assignment".


    thanks a lot !

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    20
    To eliminate the problem, either u use function prototypes declaration, or you arrange your function wall_collision before the function movement, as function should be declared before they are used.

    Code:
    void wall_collision(int num_discs) {
         double smallx,smally,bigx,bigy;
         int k;
         if(.........
    }
    
    void movement(int num_discs) {
         double i=basic_data[0];
         int j,k;
         .......
         .......
         wall_collision(num_discs);
         .....
    }
    int main(void) {
         int num_discs /* it is pre-defind */;
         movement(num_discs);
         return 0;
    }
    To use function prototypes, do as follows:
    Code:
    void movement(int); 
    void wall_collision(int );
    
    int main(void) {
         int num_discs /* it is pre-defind */;
         movement(num_discs);
         return 0;
    }
    
    void movement(int num_discs) {
         double i=basic_data[0];
         int j,k;
         .......
         .......
         wall_collision(num_discs);
         .....
    }
    
    void wall_collision(int num_discs) {
         double smallx,smally,bigx,bigy;
         int k;
         if(.........
    }
    Hope it helps.
    Last edited by learninC; 05-14-2005 at 05:58 AM.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    6
    it fixed it, thank u !

    ---> any idea about the second problem ?

    the structure: "disc" is defined outside the functions and so is the array "basic_data".

    ??

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    6
    thanx anyway, guess I'm still an idiot in C...

    "=" instead of "==" in IF statement........

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 08-23-2008, 01:16 PM
  2. error: conflicting types for 'basename'
    By samf in forum C Programming
    Replies: 3
    Last Post: 09-20-2007, 09:22 AM
  3. The Interactive Animation - my first released C program
    By ulillillia in forum A Brief History of Cprogramming.com
    Replies: 48
    Last Post: 05-10-2007, 02:25 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Conflicting types of typedef error
    By advocation in forum C++ Programming
    Replies: 4
    Last Post: 03-22-2005, 05:26 PM

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