![]() |
|
#1
|
|||
|
|||
Error 5 error C2440: 'return' : cannot convert from...c++ dll - return/convert to a string from a function that retunds char[]
Hi all, Need a little help here. I am trying to return the MAC of a codec using the following function but cant work out how to convert the Buffer from char[5] to char or other string type as the return value. This will be used in a DLL in a VB app. (Basically because my knowledge of C is very low) The following code returns this error Error 5 error C2440: 'return' : cannot convert from 'char [5]' to 'char' j:\Indigo Vision\COM\VBserial.dll\IVserial.cpp 194 Its probably obvious but I can seem to convert it Tim Norton CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
Re: Error 5 error C2440: 'return' : cannot convert from...For starters, your function signature suggest that you wish to return a single char, not an array of char. Secondly, if you want to convert it to a string object, most strings will have a constructor that takes a char* (or char[]). Try
CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: Error 5 error C2440: 'return' : cannot convert from...I had alreay tried that as it seemed logical but get this error
Error 5 error C2440: 'return' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'char *' j:\Indigo Vision\COM\VBserial.dll\IVserial.cpp 198 these are the includes I have. Am I missing one? CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
Re: Error 5 error C2440: 'return' : cannot convert from...You have to change your function to return a string, not a char*.
|
|
#5
|
|||
|
|||
Re: Error 5 error C2440: 'return' : cannot convert from...did that last night too but get this error, which I dont understand
Error 9 error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl DisplayDeviceInfo(struct tagVBDEVICEINFO const *)" (?DisplayDeviceInfo@@YA?AV?$basic_string@DU?$char_ traits@D@std@@V?$allocator@D@2@@std@@PBUtagVBDEVIC EINFO@@@Z) referenced in function "char __stdcall Nortronics::GetMAC(char *)" (?GetMAC@Nortronics@@YGDPAD@Z) IVserial.obj |
|
#6
|
|||
|
|||
Re: Error 5 error C2440: 'return' : cannot convert from...OK, I feel like an idiot now.
The second error wasfor a differnet function sorry |
|
#7
|
|||
|
|||
Re: Error 5 error C2440: 'return' : cannot convert from...I can't really tell without looking at all of the code, but do the function signatures exactly match. In other words...
CPP / C++ / C Code:
|
Recent GIDBlog
More photos on Flickr by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Message Class | TransformedBG | C++ Forum | 5 | 29-Nov-2006 21:28 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| Help wit my source code compiler errors | Krandygrl00 | C++ Forum | 1 | 06-Jun-2005 08:14 |
| Palindrome Without Library Functions? | fito | C Programming Language | 2 | 30-Nov-2004 02:53 |
| Revising Script style ?????? | pepee | MySQL / PHP Forum | 4 | 14-Apr-2004 04:59 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The