User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,630 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 1765 | Replies: 3 | Solved
Reply
Join Date: Nov 2007
Posts: 15
Reputation: RexxX is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
RexxX RexxX is offline Offline
Newbie Poster

Incompatible Type for Argument 1

  #1  
Nov 18th, 2007
Also argument 2 makes integer from a pointer with a cast. One argument is a struct declared in an included library. It's declared like:
struct pixelst *lzwArr;

lzwArr = (struct pixelst *) malloc(pixels); // pixels is an int

the second argument is an unsigned int 2D array. It's used in a function to store hex numbers. It's declared like:

 int dlzwHeight = (int)lzwArr[0].height; //cast to int
        int dlzwWidth = (int)lzwArr[0].width; //cast to int

        unsigned int dlzwArr[ dlzwHeight ][ dlzwWidth ];
        dlzwFun(lzwArr, dlzwArr); //line giving the error

The reason I cast the struct variables to int is because they start as hex numbers. Can you see the problem from the code here?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: Incompatible Type for Argument 1

  #2  
Nov 18th, 2007
> The reason I cast the struct variables to int is because they start as hex numbers
This makes no sense at all.
What does this do?
int a = 10;
int b = 0xa;
printf( "%d %d\n", a, b );
The fact that the constant was written in hex, or was read from a string in hex and converted to an int doesn't make a bean of difference.

> unsigned int dlzwArr[ dlzwHeight ][ dlzwWidth ];
You appear to be trying to declare a variable sized array. If your compiler allows this (at all), it is non-standard behaviour.

> lzwArr = (struct pixelst *) malloc(pixels);
1. You cast the result of malloc. There is no need to do this if your C program is correct, and it hides problems if your C program is wrong.
2. The form should be
lzwArr = malloc ( pixels * sizeof *lzwArr ); I'm guessing you allocated a hell of a lot less than you though you had, and have been trashing lots of memory as a result.
Reply With Quote  
Join Date: Nov 2007
Posts: 15
Reputation: RexxX is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
RexxX RexxX is offline Offline
Newbie Poster

Re: Incompatible Type for Argument 1

  #3  
Nov 18th, 2007
How would I malloc my 2D array dlzwArr with variables?
Reply With Quote  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: Incompatible Type for Argument 1

  #4  
Nov 18th, 2007
A link
Last edited by Aia : Nov 19th, 2007 at 12:04 am.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC