Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > Strange Compile Error

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Strange Compile Error
Moderator:
RSKV

Post Reply
Follow this topic



Strange Compile Error

Franky posted on 18 Jun 2011 10:37 AM PST
Member
2 Forum Posts

 Hello,


 


I am attempting to connect with a USB device using the CyUSB.dll libraries using Visual Studio. I was using the template here: http://www.cypress.com/?docID=28357. I haven't gotten too far. So far this is what I have.


 


 USBDeviceList usbDevices = gcnew USBDeviceList(CyConst::DEVICES_CYUSB);


 


Which is adapted from:


 


usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);


 




Used in the above mentioned template. I am doing this in Visual C and the template is in C#; so I am assuming that my issues are arising form this. Here is my compiler error:


 


 1>Driver.cpp(9): error C2664: 'CyUSB::USBDeviceList::USBDeviceList(unsigned char)' : cannot convert parameter 1 from 'CyUSB::USBDeviceList ^' to 'unsigned char'


1>          No user-defined-conversion operator available, or


1>          There is no context in which this conversion is possible


 


I don't understand why this is causing an issue for me? This line compiles fine:


 


unsigned char option = CyConst::DEVICES_CYUSB;


 


It even prints a value for option if I print it. However passing option to the UsbDeviceList constructor throws the same error. I am somewhat new to Microsoft development, so any advice would be nice.


 


Thanks




Re: Strange Compile Error

aasi posted on 18 Jun 2011 07:34 PM PST
Cypress Employee
1090 Forum Posts

Most probably VS expects you to explicitly type cast CyConst::DEVICES_CYUSB to ((unsigned char)CyConst::DEVICES_CYUSB).

Regards,

Anand



Re: Strange Compile Error

Franky posted on 19 Jun 2011 04:31 PM PST
Member
2 Forum Posts

It doesn't seem like this is the issue. After the change this is what I have.

USBDeviceList usbDevices = gcnew USBDeviceList((unsigned char)CyConst::DEVICES_CYUSB);

And here is the compile error:

1>Driver.cpp(9): error C2664: 'CyUSB::USBDeviceList::USBDeviceList(unsigned char)' : cannot convert parameter 1 from 'CyUSB::USBDeviceList ^' to 'unsigned char'

1>          No user-defined-conversion operator available, or

1>          There is no context in which this conversion is possible

1>  Generating Code...

This doesn't make sence to me as I can store CyConst::DEVICES_CYUSB as an unsigned char. And when I do and pass it to the constructor I still get this error.



Re: Strange Compile Error

aasi posted on 19 Jun 2011 06:56 PM PST
Cypress Employee
1090 Forum Posts

Interesting. Please attach your project here so that I can figure out what exactly is going wrong.

Regards,

Anand






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20