![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningDoes the warning give a line number or otherwise point to some specific place in your code?
|
|
#2
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningCPP / C++ / C Code:
cast it to CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningHi!
dlp: the lines giving the warning are the ones I signaled with comments in the code. ahbi82: when casting in malloc: Code:
I get a new warning in the malloc line, and besides the other lines keep on warning. |
|
#4
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningI tried putting together what you have posted but it is missing a lot of stuff.
I did see this though for starteres: CPP / C++ / C Code:
Get it running as well as you can and post the entire thing back (in C++ (not 'code') tags) ...so we can see EXACTLY what you are seeing... Howard; PS: good to have gidforums back on line, looked like a pretty good meltdown... I note, however, that these posts are not in sequence in my browser... You gettin that too? |
|
#5
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningHi again,
I haven't found the solution yet, but I discovered another problem that perhaps is related, this time the compiler triggers a compilation error not a warning. I'm writing a function to release the previous allocated memory for the dynamic list, here is the problem: CPP / C++ / C Code:
I think that the second error is related with the warning, the warning can be solved with a cast, but how to solve the second one?? Any ideas? Thanks |
|
#6
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningHi Howard,
I didn't post the other data type: conductivity_cell_t, as I thought it was not related with the warning. Here is it: CPP / C++ / C Code:
data_unit_t *conductivity_values, is the head of a concatenated list, therefore I control everything in the program from the struct conductivity_cell_t (kind of parent struct), as there I have among other stuff the access point to the dynamic list. The function "Add_Data_Element" accepts as an argument a pointer to the conductivity_cell_t struct, then I acceed the beginning of the list and I work with it. here is a simplification of the code: CPP / C++ / C Code:
|
|
#7
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningSheez... I'll have to go now and won't return until late tonight. sorry
Maybe someone else can help in the meantime. I tried your latest code and got lots of warnings. It needs work fer sher. I would start building it back up from the beginning. Start with a simple main() and data declarations including the structures. NO functions or calls at this point. Make some temporary things in main() to look at and manipulate your data. Get comfortable with that and ensure that everything behaves as you expect. Add in your first function and prototype in header. If it gives problems reduce it to a minumum and add stuff one at a time. Make sure what you pass to it and back is what you expect. (major problem causer) Repeat.... Linked lists can be pretty confusing, but building one thing at a time helps me understand what is going on as I'm going on building... Here are the majors of those warnings: CPP / C++ / C Code:
so recompile often , and put error reporting on full blast Good Luck! (one step at a time...) Howard; |
|
#8
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningQuote:
Change the typedef to something like: CPP / C++ / C Code:
1. If it is a C program (not C++) and if you have included <stdlib.h> no casts are required anywhere. If you need a cast in this function, then you are doing something wrong somewhere else. 2. If it is a C++ program, you will need casts on the malloc() stuff, but I respectfully suggest that C++ programs use new and delete rather than malloc() and free() 3. I also respectfully suggest that you never cast the result of an expression on the left-hand side. Current versions of GNU compilers (4.something) have changed "deprecated" to "prohibited". (It wasn't part of the C standard, but for some god-awful reason, previous versions of the compilers allowed it. It's never necessary, and it's just downright "wrong".) Regards, Dave |
|
#9
|
|||
|
|||
double concatenated dynamic list - different type assignment warningHi there,
I am doing a concatenated dynamic list using structs as each data unit, and pointers to structs to access the previous and the next data unit, here is the struct definition: CPP / C++ / C Code:
Everything works fine, however I can’t get rid of a warning message telling: “Warning: Assignment from incompatible pointer type”. I guess that the reason is that I assign a pointer to null to a pointer to data_unit_t, which are actually different types. If I cast before the assignment I get rid of the warnings, however in one of the lines I get a new warning telling me that “leftside cast is deprecated”. See the comments in the code: CPP / C++ / C Code:
Any ideas?? Last edited by LuciWiz : 31-May-2007 at 11:56.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#10
|
|||
|
|||
Re: double concatenated dynamic list - different type assignment warningQuote:
Bottom line: if you have to use casts of any kind in the function you showed, then you need to do something else. (Assuming it's C and not C++). Regards, Dave |
Recent GIDBlog
Welcome to Baghdad by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C++ class -- Please help | vnca_1 | C++ Forum | 3 | 14-Jun-2006 12:31 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| linked list error message | Krandygrl00 | C++ Forum | 4 | 22-Jun-2005 14:13 |
| Double output | leanieleanz | C++ Forum | 1 | 11-Mar-2005 20:19 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The