473,770 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(dlle xport) String* APIENTRY function_name(
String* s).
Please help me out from these errors.
Thanks.
Oct 12 '07 #1
6 1387
>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(dlle xport) 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(dlle xport) 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(dlle xport) 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(dlle xport) 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(dlle xport) 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(dlle xport) 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
3394
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 function call funcRet()is made which returns the expected argument type for the function call by reference funcByRef(class A&); The only way to get around this probelm is to first call the funcRet(), assign its value to a variable and pass that...
3
1764
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 findng that in my method definitions, I am having to fully scope the names of any other functions I am calling. I do not understand this. The clas declaration code look some thing like this: class A: public Singleton<A> { public:
4
2394
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, fast database abstraction layer which conforms to the behavior of the MySQL functions in PHP. This means that a large amount of porting work could be made simple using this porting layer if the application was originally used PHP's native MySQL...
2
3390
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 = _afxRichEditState;
2
1239
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 the console appliation, I get lots of errors in stdlib.h - C2733 and C2059 errors. Does anyone know how to resolve?
3
8081
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 LNK2028: unresolved token (0A000007) "extern "C" void __clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)" (?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public: virtual __thiscall...
3
3960
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 assemlies (DLLs) using MSVC8 (VS2005) with the /clr option. However, I get hundreds of linker errors (mostly LNK2028) because assembly B uses native types defined in assembly A. I could easily get rid of the problem by #including the original source...
66
3642
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 (function(socket, args) == -1) { perror("function"); exit(EXIT_FAILURE); } I feel that the ifs destroy the readability of my code. Would it be
17
6915
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 errors. The project uses a large header file 'precompiled.h' which includes two other header files, math/math.h and math/vector.h in that order. I've already disabled the ALWAYS_SEARCH_USER_PATHS which was causing other errors. From...
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8905
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3987
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.