Help me this runtime trouble on pointers

This is a discussion on Help me this runtime trouble on pointers within the C Programming forums, part of the General Programming Boards category; Hello, I am just trying to call a function in main.c while I am getting following trouble, somebody kindly help ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    13

    Help me this runtime trouble on pointers

    Hello,

    I am just trying to call a function in main.c while I am getting following trouble, somebody kindly help to know
    where I am wrong


    Fileopr.h
    ----------
    Code:
    __declspec(dllexport) void FormatMatrixComp(float * matrix, short int *nmat, short int *nrow, short int *ncol, short int * comp_flag, short int * idbaseMat,  
    int * idtargetMat);
    main.c
    --------
    Code:
    #include Fileopr.h
    
    int matrix[][2]={{1,2},{4,5},{7,8}}; 
    int nmat =10;
    int nrow=5;
    int ncol=4;
    int comp_flag=3;
    int idbaseMat=2;
    int idtargetMat=1;
    
    int   main( int argc, char **argv )
    {
      
     FormatMatrixComp(matrix,nmat, nrow, ncol, comp_flag, idbaseMat, idtargetMat);
    }
    FormatMatrx.c
    --------------
    Code:
    #include Fileopr.h
    
    void FormatMatrixComp(float * matrix, int *nmat, int *nrow, int *ncol, int * comp_flag,int * idbaseMat, int * idtargetMat)
    {
     Other than "matrix" other parameters showing debugg look up shows following error at  run time
      //  CXX0030: Error: expression cannot be evaluated
      // ( I am not seeing passed values )
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    > FormatMatrixComp(matrix,nmat, nrow, ncol, comp_flag, idbaseMat, idtargetMat);
    Given that all the parameters are pointers, just how many errors are you getting when you compile this code?

    Whilst your compiler may be calling them "warnings" and providing you with an executable to run, this doesn't take away the fact that the code is broken.

    Fix your code so it compiles cleanly before trying to run it.
    Preferably with the warning level turned up.
    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.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear Salem,

    Thanks very much for your reply.

    Fine, I have assigned the parameter values(hard coded) in my main function itself so I hope I can see all these values while the debugger reaches at the actual fuction definition. However, I could see the matrix value what I have hardcoded there, then why not I dont see other parameters??? code is breaking some lines so I want to know wheather I did something wrong in my written code that I posted above else it should be something else.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    How about beginning with three things that are actually consistent?

    Code:
    __declspec(dllexport) void FormatMatrixComp(float * matrix, short int *nmat, short int *nrow, short int *ncol, 
    short int * comp_flag, short int * idbaseMat, int * idtargetMat);
    
    void FormatMatrixComp(float * matrix, int *nmat, int *nrow, int *ncol, int * comp_flag,int * idbaseMat, int * idtargetMat)
    {
     Other than "matrix" other parameters showing debugg look up shows following error at  run time
      //  CXX0030: Error: expression cannot be evaluated
      // ( I am not seeing passed values )
    }
    
    int matrix[][2]={{1,2},{4,5},{7,8}};
    int nmat =10;
    int nrow=5;
    int ncol=4;
    int comp_flag=3;
    int idbaseMat=2;
    int idtargetMat=1;
    int   main( int argc, char **argv )
    {
     FormatMatrixComp(&matrix[0][0],&nmat, &nrow, &ncol, &comp_flag, &idbaseMat, idtargetMat);
    }
    All the red things are inconsistencies between the three things (caller, declaration, definition).
    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.

  5. #5
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear Salem,

    Thanks you very much for the answer, it is working fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with pointers
    By wayne188 in forum C Programming
    Replies: 3
    Last Post: 01-26-2010, 11:47 AM
  2. Trouble with pointers..
    By elfjuice in forum C Programming
    Replies: 7
    Last Post: 11-25-2007, 12:19 AM
  3. Pointers trouble
    By saahmed in forum C Programming
    Replies: 39
    Last Post: 03-24-2006, 03:08 AM
  4. trouble with pointers
    By lucaspewkas in forum C Programming
    Replies: 3
    Last Post: 05-20-2005, 06:13 AM
  5. Trouble with pointers
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2002, 05:08 PM

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