473,378 Members | 1,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Errors in VC.Net porting

Hi all,
I am porting an code written in VC++ to VC.Net to make it manage. But in
Managed VC we dont use "const" keyboard at all. but my code is using it very
frequently, so is their any alternative to it or we have to remove the
"const" keyword from our code completely. Please suggest me the solution.
Secondly i am getting one error as::
error C4439: 'function_name' : function definition with a managed type in
the signature must have a __clrcall calling convention.
code is::extern "C" __declspec(dllexport) String* APIENTRY function_name(
String* s).
Please help me out from these errors.
Thanks.
Oct 12 '07 #1
6 1361
>I am porting an code written in VC++ to VC.Net to make it manage. But in
>Managed VC we dont use "const" keyboard at all. but my code is using it very
frequently, so is their any alternative to it or we have to remove the
"const" keyword from our code completely.
You should still be able to use const in those parts of your code that
are still native C++, but as you've found, there's not the same notion
of const in the managed world.

BTW, you mention managed VC - if that means versions prior to VS2005,
you might be wise to move to VS2005 and use the much neater C++/CLI.

Dave
Oct 12 '07 #2
Thanks David for this suggestion. but you have not answered my second
question :: i am getting this error ::
error C4439: 'function_name' : function definition with a managed type in
the signature must have a __clrcall calling convention.

my code is::extern "C" __declspec(dllexport) String* APIENTRY function_name(
String* s).
Please help me out from these errors.
"David Lowndes" wrote:
I am porting an code written in VC++ to VC.Net to make it manage. But in
Managed VC we dont use "const" keyboard at all. but my code is using it very
frequently, so is their any alternative to it or we have to remove the
"const" keyword from our code completely.

You should still be able to use const in those parts of your code that
are still native C++, but as you've found, there's not the same notion
of const in the managed world.

BTW, you mention managed VC - if that means versions prior to VS2005,
you might be wise to move to VS2005 and use the much neater C++/CLI.

Dave
Oct 12 '07 #3
>error C4439: 'function_name' : function definition with a managed type in
>the signature must have a __clrcall calling convention.

my code is::extern "C" __declspec(dllexport) String* APIENTRY function_name(
String* s).
Please help me out from these errors.
Presumably you need to specify __clrcall. Have you tried adding it ?

Dave
Oct 12 '07 #4
Dipesh_Sharma wrote:
Thanks David for this suggestion. but you have not answered my second
question :: i am getting this error ::
error C4439: 'function_name' : function definition with a managed type in
the signature must have a __clrcall calling convention.

my code is::extern "C" __declspec(dllexport) String* APIENTRY function_name(
String* s).
Please help me out from these errors.
Dipesh:

I am not an expert on managed code, but I am sure extern "C" is not
allowed on a function with managed types in the signature.

It would appear you are trying to convert your entire application to use
managed types. If you want to do this you might as well rewrite the
whole application in C#. The big advantage of Managed C++ (or C++/CLI)
is that you can easily mix managed and unmanaged code in your
application, and you do not seem to be taking advantage of this.

IMHO, you should also take serious note of David Lowndes' suggestion to
move to VS2005. You can also use the latest beta version of VS2008
(which is free). Managed C++ as used in Vs2002 and VS2003 is obsolete,
and IMHO it would be a huge mistake to migrate existing unmanaged code
to it.

--
David Wilkinson
Visual C++ MVP
Oct 12 '07 #5
HI david yes you were right that i am porting my code written in VC++ to make
it managed. I am working on VS2005, and i a not able to remove the error
c4439 of __clrcall. Please help me by providing the exact syntax of exporting
the previously written functions in VC++ to export them in VC.Net.
My code is like::extern "C" __declspec(dllexport) String* APIENTRY
function_name( String* s). And how should i mix both native & managed code in
a single project??
Thanks.

"David Wilkinson" wrote:
Dipesh_Sharma wrote:
Thanks David for this suggestion. but you have not answered my second
question :: i am getting this error ::
error C4439: 'function_name' : function definition with a managed type in
the signature must have a __clrcall calling convention.

my code is::extern "C" __declspec(dllexport) String* APIENTRY function_name(
String* s).
Please help me out from these errors.

Dipesh:

I am not an expert on managed code, but I am sure extern "C" is not
allowed on a function with managed types in the signature.

It would appear you are trying to convert your entire application to use
managed types. If you want to do this you might as well rewrite the
whole application in C#. The big advantage of Managed C++ (or C++/CLI)
is that you can easily mix managed and unmanaged code in your
application, and you do not seem to be taking advantage of this.

IMHO, you should also take serious note of David Lowndes' suggestion to
move to VS2005. You can also use the latest beta version of VS2008
(which is free). Managed C++ as used in Vs2002 and VS2003 is obsolete,
and IMHO it would be a huge mistake to migrate existing unmanaged code
to it.

--
David Wilkinson
Visual C++ MVP
Oct 17 '07 #6
Dipesh_Sharma wrote:
HI david yes you were right that i am porting my code written in VC++ to make
it managed. I am working on VS2005, and i a not able to remove the error
c4439 of __clrcall. Please help me by providing the exact syntax of exporting
the previously written functions in VC++ to export them in VC.Net.
My code is like::extern "C" __declspec(dllexport) String* APIENTRY
function_name( String* s). And how should i mix both native & managed code in
a single project??
Dipesh:

Maybe I am not clear what you are doing. What is String? If it is
managed and you are using VS2005, then you should be using String^, not
String*.

But my point was that in C++/CLI you do not need to convert each and
every function to managed.

To mix managed and unmanaged code you just do it (that's why it's called
IJW - It Just Works), though there are things you cannot do. I am no
expert here, but I think managed code can generally call unmanaged code,
but not vice-versa.

A good introductory book on C++/CLI is Ivor Horton's "Beginning C++ 2005."

--
David Wilkinson
Visual C++ MVP
Oct 17 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mangi03 | last post by:
Hi, I came acrosss g++ compile errors whenever I make a function call by reference and found out from the test program that compiler is treating the function argument differently when another...
3
by: Alfonso Morra | last post by:
I have some code that I am porting over from C. It is full of static functions and global variables. I have got around this by wrapping most of the code in a singleton object. However, I am...
4
by: Chris Travers | last post by:
Hi all; A few years ago, I set about porting a PHP application from MySQL to PostgreSQL, after realizing that MySQL wasn't going to be able to handle it. In order to do this, I built a light,...
2
by: Senapathy | last post by:
VC++ .NET 2003 Standard Edition Win XP, SP2 Hi, I have a code that builds under VC6.0, but fails to link in VC7.1. The offending code is as follows: _AFX_RICHEDIT_STATE* const pEditState...
2
by: Jim Bish | last post by:
I am porting some code form vs2003 to vs2005 - it is unmanaged CPP. The solution consists of several library projects and a console project. The library projects all build fine but when I get to...
3
by: Chucker | last post by:
Hi Folks, I got a Wrapper Dll around a native C++ static library. In .NET 1.1 this worked fine. When moving to .NET 2.0 I get a couple of unresolved externals / linker errors: Error 16 error...
3
by: dfranzen | last post by:
Hi *, I'm in the process of porting an ANSI C++ project from a UNIX platform to .NET. After "getting rid of" some platform-specific stuff I managed to compile the first two libraries into mixed...
66
by: Johan Tibell | last post by:
I've written a piece of code that uses sockets a lot (I know that sockets aren't portable C, this is not a question about sockets per se). Much of my code ended up looking like this: if...
17
by: qartar | last post by:
As the title says, I am porting some code from MSVC (not sure which version, using Visual Studio 2008), which compiles without errors or warnings, to GCC 4.0 which generates a large number of generic...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.