does this error make sense

This is a discussion on does this error make sense within the C Programming forums, part of the General Programming Boards category; Usually when MSVC tells me something is wrong, something is wrong. But here is a chunk of my code and ...

  1. #1
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168

    does this error make sense

    Usually when MSVC tells me something is wrong, something is wrong.

    But here is a chunk of my code and i think this error is bogus.

    Code:
    1>.\SnapLib.c(42) : warning C4047: 'function' : 'uInt8 **' differs in levels of indirection from 'uInt8 *'
    1>.\SnapLib.c(42) : warning C4024: 'AnalogueCardInit' : different types for formal and actual parameter 2
    Code:
    int AnalogueCardInit( uInt8 *image1D, uInt8 **image2D);
    int main(void){
    	uInt8* Buffer1D = NULL;
    	uInt8** Buffer2D = NULL;
    
    	int nothing = 0;
    	nothing = AnalogueCardInit( Buffer1D, *Buffer2D);
    }
    int AnalogueCardInit ( uInt8 *image1D, uInt8 **image2D){
    ...
    }
    This will be part of a library and Buffer1D will hold the values and Buffer2D will point to parts of Buffer1D making a 2D array
    Last edited by chico1st; 05-27-2008 at 11:26 AM.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    The second argument is uInt8** and Buffer2D is uInt8**, so why do you dereference Buffer2D to pass it to this function?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,931
    The error (or rather, warning) is not bogus. It is just telling you that Buffer2D is a uInt8**, so *Buffer2D is a uInt8*. However, the second parameter of AnalogueCardInit is a uInt8**, not a uInt8*, yet you pass *Buffer2D as the argument.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    From what I can see you are passing a pointer to AnalogueCardInit, but the function is expecting a pointer of a pointer (second argument). You should just pass Buffer2D, without the indirection.

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  5. #5
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    so when passing a 2D array into a function you have
    Code:
    int main(void){
         int**something;
         foo(something);
         return 0;
    }
    function foo(**something){
    }
    edit: I want them both to be passed by reference if that makes a difference. I want the values in main to change when foo does stuff
    Last edited by chico1st; 05-27-2008 at 11:36 AM.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,931
    I want them both to be passed by reference if that makes a difference. I want the values in main to change when foo does stuff
    To begin with, have you worked with one dimensional arrays?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    yes i have
    i thought when you wanted to pass by reference it looks like
    &Variable
    1Dstring
    *2Dstring
    **3Dstring

    but i suppose it is really

    &Variable
    1Dstring
    2Dstring
    3Dstring

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. does it make any sense
    By ExDHaos in forum C++ Programming
    Replies: 0
    Last Post: 05-23-2009, 08:06 AM
  2. Junk pointer too high to make sense.
    By Yasir_Malik in forum C++ Programming
    Replies: 7
    Last Post: 03-21-2006, 12:42 PM
  3. does this make sense ??
    By agarwaga in forum C++ Programming
    Replies: 14
    Last Post: 03-08-2006, 06:10 PM
  4. Get sense of internal linkage and external linkage
    By gandalf_bar in forum C++ Programming
    Replies: 1
    Last Post: 10-14-2003, 05:57 AM
  5. WinXP Upgrade Doesn't Make Any Sense
    By Troll_King in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 10-25-2001, 04:18 PM

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