GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-May-2008, 06:27
sapan_shah143 sapan_shah143 is offline
New Member
 
Join Date: May 2008
Posts: 11
sapan_shah143 is on a distinguished road

error C2440: 'initializing' : cannot convert from 'mbException (__cdecl *)(mbRequestP


hi every one i got this error. i need help regarding this.

error C2440: 'initializing' : cannot convert from 'mbException (__cdecl *)(mbRequestPDU)' to 'BYTE'

code for function handler is

CPP / C++ / C Code:
typedef mbException ( *pmbFunctionHandler ) ( mbRequestPDU );

typedef struct
{

	BYTE mbFunctionCode;   /* variable for function code */
	pmbFunctionHandler mbHandler;  /* variable for function call */

}mbFunctionHandler;


and code for array of function call

CPP / C++ / C Code:
static mbFunctionHandler xFuncHandlers[mbMaxHnadlers] = {

	#if mbReadCoilStatus_EN > 0
:arrow: 			(mbReadCoilStatus, mbfunReadCoilStatus),
	#endif

	#if mbReadInputStatus_EN > 0
			(mbReadInputStatus, mbfunReadInputStatus),
	#endif

	#if mbReadOutputRegister_EN > 0
			(mbReadOutputRegister, mbfunReadOutputRegister),
	#endif

};

i got error at the point arrow shows.

can any one help me. BYTE is unsigned character
Last edited by LuciWiz : 21-May-2008 at 00:55. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 15-May-2008, 08:40
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,703
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: error C2440: 'initializing' : cannot convert from 'mbException (__cdecl *)(mbRequ


Quote:
Originally Posted by sapan_shah143
error C2440: 'initializing' : cannot convert from 'mbException (__cdecl *)(mbRequestPDU)' to 'BYTE'

...BYTE is unsigned character
Sometimes error messages are not very enlightening as to the specific nature of the problem.

Here's one thing that I see. Although it's not exactly obvious, I'm thinking it could lead to that error message, but regardless of that particular message, it's just wrong:

Your initializer list for the array of structs is wrong. Items in an initializer list are enclosed in {} braces, not () parentheses.

So, try:

CPP / C++ / C Code:
    #if mbReadCoilStatus_EN > 0
            {mbReadCoilStatus, mbfunReadCoilStatus}, /* {} braces, not () parentheses */
    #endif
.
.
.



Regards,

Dave
Last edited by davekw7x : 15-May-2008 at 09:31.
  #3  
Old 15-May-2008, 23:09
sapan_shah143 sapan_shah143 is offline
New Member
 
Join Date: May 2008
Posts: 11
sapan_shah143 is on a distinguished road

Re: error C2440: 'initializing' : cannot convert from 'mbException (__cdecl *)(mbRequ


thanks a lot dave. i got solution. it was a silly mistake
 
 

Recent GIDBlogObservations of Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert the input into square yards pjpav Java Forum 1 08-Oct-2005 07:43

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:49.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.