|
Many thanks
Sorry to disturb you again, but the problem looks bigger:
I create a new very simple project: a class library in VC NET, it is the only one file that I edited...
<br />
<br />
#pragma once<br />
<br />
using namespace System;<br />
<br />
namespace LibreriaDiClassiCppNET<br />
{<br />
public __gc class Class1<br />
{<br />
Class1(){<br />
}<br />
~Class1(){<br />
}<br />
void Foo(){<br />
int* p;<br />
p=new int;<br />
delete p;<br />
}<br />
<br />
};<br />
}<br />
errors came during the link process...it don't like new and delete operator.
If I cut that 2 lines then the DLL is created (OK, it is empty, but it works)
Can you tell me why?
Cheers,
Russell
|
|
|
|
|
What are the exact error messages you get?
Regards,
Nish
Fly on your way like an eagle
Fly as high as the sun
On your wings like an eagle
Fly and touch the sun
|
|
|
|
|
Hi,
the error is LNK2001 in doth cases ('new' and 'delete' operators).
It tells
error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@$$FYAPAXI@Z)
error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
As you can see the compiler works, the problem is the linker....but i haven't change anything into the settings of the solution: it is a new project (library of classes in C++ NET).
I think that I'm missing some rule that tells that I can't use 'new' and 'delete' into the dll in classes in managed code,...but, if exist, it looks like a very strange rule! : this operators are basically and very important in C++ (managed or unmanaged).
Let me know, thanks
Cheers,
Russell
|
|
|
|
|
Russell,
Since you are using native C++ wrapped in Managed C++, I believe you must include stdio.h and any applicable libraries. Managed C++ actually uses __gc new to create managed objects. Also, you need to be aware of the VS 2003 MC++ loader lock problem. Please, read: http://www.codeproject.com/scrapbook/semicolon_2.asp[^]. After dealing with that issue (and others) for years, I was very happy to upgrade to 2005 and learn the new syntax.
Geo
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi.
I'm calling managed (C#) code from (unmanaged) Fortran. The Fortran code uses an unmanaged C/C++ Flat API (in a DLL), which calls into a managed C++ wrapper (currently in a separate DLL), which then calls into C# code...
I'm using Visual Studio 2005 for everything except the Fortran stuff. The Fortran code is built with Visual Studio 6.0. I have to use it because that's what the Fortran coders use.
How do I go about debugging my Fortran-to-C# bridge? Can I somehow launch an instance of VS 2005, load my DLLs, and attach to the running Fortran process to debug it? Or is there a way to debug using VS 6.0? Will I have to resort to WinDBG or something (which I've never used)?
Help. Thanks.
Just Mike
|
|
|
|
|
OK, let me reply to my own post to be more specific. I have more information.
I understand how to specify the executable for a C++ DLL (managed or unmanaged). When I do that and "Start New Instance" from VS, the executable launches as expected. However, when I try to do something that should stop me at a breakpoint, I see VS "wake up" in the sense that my breakpoint becomes live (red dot), and it even acts a little like I'm stopped at the breakpoint. But I don't see a current statement pointer, and I can't step through the code. What am I missing?
Furthermore, there doesn't seem to be an option to do something similar from a C# assembly (DLL). This is a C++ forum, of course, so I suppose that question isn't appropriate here. But it all seems related.
Help appreciated. Thanks.
Just Mike
|
|
|
|
|
Have you set the debugger mode to mixed?
Regards,
Nish
Fly on your way like an eagle
Fly as high as the sun
On your wings like an eagle
Fly and touch the sun
|
|
|
|
|
I'm having a discussion with my collueage regarding the correct coding style for
declaration of property in Interface Class, and we disagree with each other.
Can Somebody give some input to out discussion?
Which below code has a best coding style??
The difference between ex1 and ex2 is that get() and set() functions
of property Counter are explicitely declared in ex2, evenif it is
not necessary to do so in CLI.
ex1:
public Interface Class MyClass{
public:
property int Counter;
};
ex2:
public Interface Class MyClass{
public:
property int Counter
{
int get();
void set(int value);
}
};
/The Van Dao
|
|
|
|
|
It doesn't matter. However, ex2 will allow you to have a property without one of the "accessors".
public interface class ITest
{
property int Value;
};
public ref class Test1 : ITest
{
public:
virtual property int Value;
};
public ref class Test2 : ITest
{
int m_value;
public:
virtual property int Value
{
int get()
{
return m_value;
}
void set(int value)
{
m_value = value;
}
}
};
public ref class Test3: ITest
{
int m_value;
public:
property int Value
{
virtual int get()
{
return m_value;
}
virtual void set(int value)
{
m_value = value;
}
}
};
public interface class ITest2
{
property int Value
{
int get();
void set(int value);
}
};
public ref class Test4: ITest2
{
int m_value;
public:
virtual property int Value
{
int get()
{
return m_value;
}
void set(int value)
{
m_value = value;
}
}
};
public ref class Test5 : ITest2
{
public:
virtual property int Value;
};
public ref class Test6: ITest2
{
int m_value;
public:
property int Value
{
virtual int get()
{
return m_value;
}
virtual void set(int value)
{
m_value = value;
}
}
};
-- modified at 12:22 Friday 13th April, 2007
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I am using C++ 2005 with Visual Studio. When I set a breakpoint and the application stops at that breakpoint I want to step into the method that is being called. F11 is supposed to step into the method but it behaves exactly as pressing F10 (step over). I want to be able to step into a function but I can't. Does anyone have any idea what is going on here?
Thanks,
Buck
Buck
|
|
|
|
|
Are you using C++/CLI ? There are forums for vanilla C++, and for IDE issues.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Could be something to do with your keyboard mapping settings, check Tools | Options | Environment | Keyboard. I set mine to "Visual C++ 6" because thats what Im used to
|
|
|
|
|
How to print numbers(in C or C++) till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
Sebastian
|
|
|
|
|
Sebastian T Xavier wrote: How to print numbers(in C or C++) till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
And why would you want to do that?
Regards,
Nish
Fly on your way like an eagle
Fly as high as the sun
On your wings like an eagle
Fly and touch the sun
|
|
|
|
|
It sounds like a homework assignment.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
In C you can not do this, however in C++ you can easily do this..
This is how you do it
#include <iostream>
using namespace std;
int i = 0;
class A
{
public:
A()
{
cout<<i++<<endl;
}
};
void main()
{
A a[10];
}
btw dont post general C++ quries in this Message Board.
Cheers
|
|
|
|
|
|
I have written a DLL in C# that I need to call from regular old C code. I have written a managed C++ bridge that successfully calls it from a test unmanaged C++ app.
My C application is able to call the C# DLL through the managed C++ bridge DLL if I use LoadLibrary and GetProcAddress. However, when I change the C application to use static linking of the C++ bridge DLL the C application then crashes before it even gets to the first line of WinMain.
The C++ bridge DLL has a managed class declared globally as:
ref class GlobalObjects {
GlobalObjects()
{
}
public:
static MyCsharpClass ^CsharpClass = gcnew MyCsharpClass();
};
The exported functions from the DLL all refer to the CsharpClass object.
I need to keep the CsharpClass object around permanently, so this is why I declared it as static.
Any ideas?
Thanks,
David
|
|
|
|
|
David Knechtges wrote: However, when I change the C application to use static linking of the C++ bridge DLL the C application then crashes
Do you have information that says it is possible to staticly link managed code into an native project? Because it seems to me that is not possible.
led mike
|
|
|
|
|
Maybe it isn't possible - I had guessed that it would be possible since I can do a LoadLibrary and GetProcAddress, then call it and have it work.
The strange thing is, if it wasn't possible, I would expect the linker to give me a warning or error of some kind, and it doesn't. That is what puzzles me.
David
|
|
|
|
|
David Knechtges wrote: I would expect the linker to give me a warning or error of some kind
Not if you understood what a "linker[^]" is.
led mike
|
|
|
|
|
Hello frnds..
can u plz suggest me the links or ebook
which gives me information abt Socket programming from the Basic.
Thanks in advance
Born To Code
|
|
|
|
|
you can find some info in apress.pro c++/cli
http://www.flazx.com/ebook4985.php
|
|
|
|
|
sockets.com
led mike
|
|
|
|
|
Hi all.
Can i execute an maneged code from unmanaged??
I.e. suppose i have an COM interface with method:
STDMETHODIMP CMyClass::ExcecCSharpProgram()
{
IMyParams* pIface = this->m_pAnInterface;//I need to pass this pointer to executed program!!!
SomeHowExecCSharpProgram("MyProg.exe");//How i can to do this (exec my program)
SomeHowPassPointerToMyProg(pIface);//And this (pass interface pointer to executed program)
}
Please help, or point out where i can see any related topics.
THANK A LOT.
|
|
|
|