473,756 Members | 7,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is the meaning of "lacks a cast" when compile

12 New Member
when I compile my code, it show :
WARNING : passing `int' to argument 1 of `deleteQueue(it emType *, queue *)' lacks a cast
What is the meaning for this warning?
Where I should coorect in my code?

Expand|Select|Wrap|Line Numbers
  1. void Print(queue *q)
  2. {
  3. int j;
  4. if ((q->tail-q->head) >=5) 
  5. {        
  6.  for(j = 0;j < 5 ;j++)
  7. {
  8. printf("\nDokumen %d sedang diproses",q->items[q->head]);
  9. deleteQueue(q->items[q->head],q);
  10. }
  11. }
  12. return;
  13. }
  14.  
  15.  
  16. void deleteQueue(itemType *nItem,queue *q)
  17. {
  18. printf(" Inside deleteQueue -> head : %d\n ", q->head);
  19. q->head = (q->head + 1);
  20. return;
  21. }
  22.  
Mar 21 '07 #1
1 5972
DeMan
1,806 Top Contributor
Basically, the compiler expects a pointer to itemType to be passed during the function. a pointer is an int, so the compiler recognises that you might deliberately be passing an integer but would like a cast to assure it that you really do intend passing that pointer intend.
A cast is acheived, by preceding the variable (in this case) with
(itemType *)
eg
Expand|Select|Wrap|Line Numbers
  1. deleteQueue((itemType *)q->items[q->head],q);
  2.  
if, however, the object at q->items[q->head] is of type itemType (and just happens to be compatible with an integer, you should pass a reference to it
viz:
Expand|Select|Wrap|Line Numbers
  1. deleteQueue(&(q->items[q->head]),q);
  2.  
you may like to be sure which of these you want to do, becauswe the one you don't will probably give you interesting side-efefects
Mar 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2618
by: LaEisem | last post by:
On-the-job, I have "inherited" a lot of old C language software. A question or two about when "casting" of null pointer constants is needed has occurred during behind-the-scenes cleanup of some of that software. That subject seems not to be addressed, at least not directly, in the C FAQ where FAQ 5.2 seems most relevant. References: * C FAQ 5.2 Null pointers (Including conditions where "casting" of null pointer...
0
1588
by: Peter Afonin | last post by:
Hello: When I try to access a SQL server or a network share from an ASP.Net application that I run on my computer, I run into security problems (for instance, I cannot execute DTS package using Trusted connection or get a file information using FileInfo class). This is probably because my application is running under PETER\ASPNET account, where PETER is my computer's name. I can solve this problem by using Impersonation. However, when...
4
3839
by: Mike Cooper | last post by:
There is something about inherited classes I evidently don't know... I wrote the following class: Class Class1 inherits System.Windows.Forms.DataGridTextBoxColumn End Class There is absolutely no added functionality to it.
10
1658
by: roy.anderson | last post by:
Error is thus: "Cast from type 'DBNull' to type 'String' is not valid." Simple, right? Well, no (or at least not for me). Here's a function, followed by the calling code below: Function GetDetails(ByVal x As String, ByVal y as String) Dim conn As New SqlConnection ("server=localhost;uid=blah;pwd=blah;database=test") Dim strSQL As String Dim ds As New DataSet()
6
11309
by: SA | last post by:
Hi all: I have an object of a base class that needs to be cast to an object of a specialized class. What is the best way to do this? (I thought about creating a constructor in the specialized class that takes an argument of the type of the base class and then copy property values over, but that seems like a hassle) --
3
2014
by: hazz | last post by:
I get an InvalidCastException "Cast from string "6<5" to type 'Boolean is not valid. for If (CInt(objBuyInfo.Budget) & " " & arrRuleList(i).operator & " " & CInt(arrRuleList(i).LeadMemberValue)) Then where arrRuleList(i).operator = ">"
8
7750
by: Mike Nolan | last post by:
As far as I can tell, Postgres has no equivalent to greatest and least functions in Oracle. Yes, you can do the same thing with a case statement, but at the expense of writing MUCH longer SQL statements. Is this something that is on or can be added to the 'to do' list? I could write a series of user-defined functions to do specific comparisons (such as comparing several dates and returning the greatest one) but there doesn't appear to...
17
2512
by: arindam.mukerjee | last post by:
I was running code like: #include <stdio.h> int main() { printf("%f\n", 9/5); return 0; }
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.