Warning messages and Numerical Recipes functions in C

This is a discussion on Warning messages and Numerical Recipes functions in C within the C Programming forums, part of the General Programming Boards category; Hi, ____________(1)______________________ I am using some "Numerical Recipes in C" routines in my C code. (I am using ludcmp() & ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    7

    Warning messages and Numerical Recipes functions in C

    Hi,

    ____________(1)______________________

    I am using some "Numerical Recipes in C" routines in my C code.
    (I am using ludcmp() & lubksb().)
    These are used to find inverse of a matrix.

    After compiling my c code, I get following warning messages.
    I have not understood them at all.
    What is the meaning of these and why did they pop up and how to remove them?

    Code:
    nrutil.h:11: warning: 'sqrarg' defined but not used
    nrutil.h:14: warning: 'dsqrarg' defined but not used
    nrutil.h:17: warning: 'dmaxarg1' defined but not used
    nrutil.h:17: warning: 'dmaxarg2' defined but not used
    nrutil.h:21: warning: 'dminarg1' defined but not used
    nrutil.h:21: warning: 'dminarg2' defined but not used
    nrutil.h:25: warning: 'maxarg1' defined but not used
    nrutil.h:25: warning: 'maxarg2' defined but not used
    nrutil.h:29: warning: 'minarg1' defined but not used
    nrutil.h:29: warning: 'minarg2' defined but not used
    nrutil.h:33: warning: 'lmaxarg1' defined but not used
    nrutil.h:33: warning: 'lmaxarg2' defined but not used
    nrutil.h:37: warning: 'lminarg1' defined but not used
    nrutil.h:37: warning: 'lminarg2' defined but not used
    nrutil.h:41: warning: 'imaxarg1' defined but not used
    nrutil.h:41: warning: 'imaxarg2' defined but not used
    nrutil.h:45: warning: 'iminarg1' defined but not used
    nrutil.h:45: warning: 'iminarg2' defined but not used
    nrutil.h is a header file which contains #define statements (besides other things) like:

    Code:
    static float sqrarg;
    #define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
    
    static double dsqrarg;
    #define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
    _________________________(2)_____________

    Also, for the same code, I get these warning messages:

    In function `main':
    warning: assignment from incompatible pointer type
    warning: passing arg 1 of `free_vector' from incompatible pointer type

    This is fragment of my code corresponding to these 2 warning messages:

    Code:
    int *indx;
    indx  =vector(1,100);
    ....
    ....
    free_vector(indx,1,100);
    Any help will be appreciated.
    (I am not expert in C. I am just implementing these functions as said in the book.)

    Regards,
    smp

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    These warnings mean you've declared variables but they are never used.
    For "warning: assignment from incompatible pointer type", I guess there're no function prototypes. ?
    Can you post the function definitions and prototypes of vector(),free_vector(),

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    7
    Quote Originally Posted by Bayint Naung View Post
    These warnings mean you've declared variables but they are never used.
    For "warning: assignment from incompatible pointer type", I guess there're no function prototypes. ?
    Can you post the function definitions and prototypes of vector(),free_vector(),
    I got my mistake for "warning: assignment from incompatible pointer type".
    I should have used ivector( ) instead of vector( ).
    ivector( ) is for "int" and vector( ) is for "float".


    But should I bother about other list of warning messages? I do not get these warning messages if I do not use -Wall option while compiling. I mean when I should treat them seriously?

    Thanks.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    You should always treat warnings seriously.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

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