|
Im not sure but I suspect your problem is related to the cpp runtime. The cpp runtime in VS2005 is not compatible with the cpp runtime in VC6 or 2003.
Are all your c++ projects dynamically linked to the runtime library? and are both using single or multi threaded version?
Try using the dependency walker to determine which libraries are being used by each dll or exe
|
|
|
|
|
:->
CV_INLINE void* cvAlignPtr( const void* ptr, int align=32 )
{
assert( (align & (align-1)) == 0 );
return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
}
CV_INLINE int cvAlign( int size, int align )
{
assert( (align & (align-1)) == 0 && size < INT_MAX );
return (size + align - 1) & -align;
}
|
|
|
|
|
Well, I guess the first point to make is that this is not managed C++ code.
I could explain what it's doing, but I'm not sure how much that would help. Where has the code come from ? Do you know what operators like & and ~ do ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Can someone please direct me to a tutorial and/or samples on the use of the String.Split method? (I seem to have problems translating C# help info for use with C++.)
LudwigKeck
|
|
|
|
|
String *limiter = S","; // --> The Limiter will be ,
Char delimiter[] = limiter->ToCharArray(); // --> Split-Method awaites a Char-Array
String* parts[] = 0; // --> Receives all parts
parts = line->Split(delimiter);
if line is "one,two,three" so the parts are
part[0] = "one"
part[1] = "two"
part[2] = "three"
The answer is very late, but i'm a newbie @ Code-Project ( since yesterday )
Regards
|
|
|
|
|
Thank you Baerten,
My problem was in C++, the code you show is C#. I have since worked it out the hard way (never did find any good documentation). In C++ the correct use is:
<br />
String^ data = "one,two,three";<br />
array<<Char>>^ separator = {','};<br />
array<<String^>>^ parts;<br />
parts = data->Split (separator);<br />
As you can see, C++ syntax is just a bit opaque, (there should be just single arrow symbols where I show double).
The module using this works fine for me now. However, now it causes a memory corruption in old legacy code that has worked for years. --- I'm not even sure how to describe it to forma help question. Such is life.
Thank you again, and welcome to the world inside!!
|
|
|
|
|
hi
i am looking for Wizard Control that allow to make step by step interface.cause i don't find it in the vc++ Express?
|
|
|
|
|
|
Hi everyone,
I am new here. I am using C to do simple communciations to a serial port (like opening,reading, writing to the serial port.....). I use the Dev C++ compiler for this. But the first thing I encountered is that my code doesnt compile without some headers..
1. <termios.h>
2. <bios.h> (even though its not used in the below example)
Do you guys have any idea where to get them. I searched the whole net but wasnt smart enough to find a place I can downlaod these headers.
Or are there any better header files that can be used in place of these. I am totally lost at this point. Would greatly appreciate any help.
The code is below
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#incldue <conio.h>
/*
* 'open_port()' - Open serial port 1.
*
* Returns the file descriptor on success or -1 on error.
*/
int
open_port(void)
{
int fd; /* File descriptor for the port */
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | _NDELAY);
if (fd == -1)
{
/*
* Could not open the port.
*/
perror("open_port: Unable to open /dev/ttyS0 - ");
}
else
fcntl(fd, F_SETFL, 0);
return (fd);
}
int main ()
{ open_port();
getch();
return 0;
}
hi
|
|
|
|
|
prashw wrote: #incldue
Well, this obviously won't compile.
This is a managed C++ forum, your question is about a compiler that doesn't even support managed C++. Try the other C++ forum, and try posting some explanation of your error messages.
And also check the 'Ignore HTML tags' thing below, so that we can see all of your code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Need an alternate code for cp command run through the system api.
Need a C code which performs the same functionality as the unix cp command provides.It should also support all the options which cp command support.
Does any one have any clue about this?
|
|
|
|
|
1 - what is the cp command
2 - what does this have to do with managed C++ ?
3 - does this mean you're going to run it on a unix system, or a Windows one ?
A google tells me that cp stands for copy. C++ has no concept of file systems, and as you've invoked Unix and posted in a MC++ forum ( which makes me cautious to jump to any conclusions ), I really need to know what system you're coding for before I can offer any API calls. Either way, no way is the Windows shell going to give you the commands that the unix shell does, exactly the same and with the exact same functionality. You'd have to write a layer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I am running my application in unix and just wants to avoid the system api call to copy files.
|
|
|
|
|
OK - standard C++ cannot help you, it knows nothing of file systems. Any calls you make will be system API calls.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
I am trying to get an event in my application when the user clicks system menu of any window. I have tried to implement this using global hooks. I have made a DLL which is installing hook in the following manner:
HINSTANCE hins;
BOOL __declspec(dllexport)__stdcall installhook()
{
hkb=SetWindowsHookEx(WH_SYSMSGFILTER,(HOOKPROC)SysMsgProc,hins,0);
//hkb=SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTProc,hins,0);
return TRUE;
}
where hins takes value from:
BOOL CHookdllApp::InitInstance ()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
hins = AfxGetInstanceHandle();
return TRUE;
}
The Callback function:
LRESULT __declspec(dllexport)__stdcall CALLBACK SysMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(MSGF_MENU == nCode)
{
LPMSG msg = (LPMSG)lParam;
//if(WM_MENUSELECT == msg->message)
//if(WM_MENUCOMMAND == msg->message)
if(WM_SYSCOMMAND == msg->message)
{
OutputDebugString("\n Got it!! \n");
}
}
return CallNextHookEx( hkb, nCode, wParam, lParam );
}
In this callback function, I get the event WM_MENUSELECT from all windows but I am not getting WM_SYSCOMMAND event which I need because I want the event when user clicks the system menu of any window.
I also tried using WH_CBT, the callback function for this is:
LRESULT __declspec(dllexport)__stdcall CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)
{
return CallNextHookEx( hkb, nCode, wParam, lParam );
}
else if(HCBT_SYSCOMMAND == nCode)
{
OutputDebugString("\n Got it!! \n");
}
return 0;
}
The problem with this hook is that I am getting events for the menu click from my application only and not from any other window.
Is there any way I can get these events?
Thanks in advance for yr help!
|
|
|
|
|
I'm using Visual Studio 2005 and I wrote a DLL program in C. I want to add a status window to this DLL that creates a window and dynamically updates labels each time the DLL is called. What is the best and easiest way to do this? Should I use C++ and Windows Forms or use MFC?
|
|
|
|
|
hi
i am working with Listview,and when i insert some data in it it range them in many columns,and i would like that arrange them just in one columns with vertical scrollbare to reach the other data in the bottom.
|
|
|
|
|
Ok. In VC++.Net 05, I've compiled a dll containing a namespace from one project in the solution. I'm now trying to use that namespace in another project but it is throwing up linking errors for the object it's compiled for the 2nd project. I have added the dll to the References in the Project Properties but nothing. If I say
> using namespace DllData
the compiler says that DllClass (in the dll) is not a member of DllNamespace. This makes sense as Intellisense is not picking up DllNamespace in the first place. I've tried including the headers for the dll source from the 1st project (which seems a bit counterproductive to me), which helps compiling the object code but then crashes the linker when it can't find the object code for the dll!
I know I'm doing something stupid or not doing something obvious. Please help!
|
|
|
|
|
I have the task of making a library that we can use from c++ (windows and linux) and c#
So far I have one project that implements the basic functionality. Its plain old c++ and boost and can be built into a windows dll or a linux library. I call it the raw library.
I have a managed library project which will hopefully implement a wrapper around the raw library to make it available to c#
In my raw lib I have a class called Raw::Car (not really but its a good example)
Car has a number of events implemented with boost::function template
eg
boost::function<void (void)> Changed;
In my managed wrapper project I have a class called Managed::Car that has a private Raw::Car* member pointing to the 'real' car object.
I want Managed::Car to subscribe to the boost events in Raw::Car and raise dot net events when the events in Raw::Car are raised.
I cant pass a pointer to a function in Managed::Car to the boost event
eg
theRawCar->Changed = boost::bind(&Managed::Car::OnRawChanged, this);
error C3374: can't take address of 'Managed::Car::OnRawChanged' unless creating delegate instance
I guessing this is because the GC could move the function?
I thought I would create a non managed template that could subscribe to the boost event and call into the managed class to raise the dot net event but a non managed class or template cant have a reference to a managed class.
Can this be overcome by using a delegate? if so how?
-- modified at 21:30 Monday 11th September, 2006
|
|
|
|
|
This works but its ugly
typedef void (*FUNC_PTR)(void);
InstrumentChangedDelegateProc^ callBack = gcnew InstrumentChangedDelegateProc(this, &ManagedVault::Instrument::OnRawChanged);
System::IntPtr p = System::Runtime::InteropServices::Marshal::GetFunctionPointerForDelegate(callBack);
FUNC_PTR ptr = (FUNC_PTR)(System::IntPtr::operator void *(p));
theInstrument->Changed = boost::bind(ptr);
|
|
|
|
|
Hi to All,
I am new to use Tree View Control
I want to save the Tree control info into DB and retrive it back and generate the same tree control again for that can any one tell me
what r the minmum necessary values like Name,index ,parent......
to store in the DB and how to use those values to generate the tree again
Can any one explain me or give me the link of the similar example.
Thanks in advance..
|
|
|
|
|
Hi,
I had to do a similar thing on the project i'm working on, but instead of using a DB, I just wrote the 'structure' of the tree to an XML file. The top-level elements represented parent tree nodes, and any child nodes of the parent nodes were written as child elements. You could then just parse the XML file, creating TreeNodes as you go through the different XML elements.
Of course it depends on how much information you need to store. For me, all I really needed was the text of the nodes and the hierarchal structure.
I hope this helps buddy!
cheeze
|
|
|
|
|
Hi All,
I've started a new application and I'm trying to keep it all C++/CLI based as opposed to MFC - as much for the exercise of getting to grips with the whole world of .NET as anything else.
I've tried to create a very simple "Singleton" class template with the following code in a "Class Library":
// singleton.h
template <class T>
public ref class Singleton
{
public:
static T^ Instance()
{
if ( nullptr == m_hInstance )
{
m_hInstance = gcnew T;
}
return m_hInstance;
}
private:
static T^ m_hInstance = nullptr;
};
//somefile.h
namespace A
{
public ref class B : public Singleton<A::B>
{
// some stuff in here, constructor/destructor kept private
};
};
In a separate "Windows Forms" application, I *try* use the following line:
A::B^ hTheThing = A::B::Instance();
...for some reason, it tells me that "Instance is not a member of A::B".
Now, if I comment out the "template" line and replace all instances of "T" with "int" in the "singleton.h" file, the following line works fine:
int^ hTheThing = A::B::Instance();
If I reinstate the "template" line but make no reference to "T" in the template body (ie: leave it all as int-based), the problem resurfaces.
Clearly I'm doing something wrong, but what exactly that is, I have no idea. Any guidance would be appreciated.
Thanks
Zyrus
Ummm... yay...
-- modified at 19:26 Monday 11th September, 2006
|
|
|
|
|
Here is a non-template singleton:
ref class B
{
B(){};
static B^ m_hInstance = gcnew B;
public:
static B^ Instance()
{
return m_hInstance;
}
};
This code does not delay the initialization to first use. Nevertheless, in your code, the base class is trying to init a derived class' private ctor which is not accessible at that point.
George
-- modified at 5:44 Thursday 14th September, 2006
|
|
|
|
|
hi,
i compiled the following code once in c++ and another time in managed c++.
In c++ it takes about 11 seconds to execute and in managed c++ it only takes 5 seconds to execute.
Why do i get twice the speed performance in managed c++ when my code is written completely in native c++ syntax?
/////////////////////////////////////////////////////////
double d1=0;
double a;
int i,j;
double d[100][100] ;
double e[100][100] ;
for (i=0;i<100;i++)
for(j=0;j<100;j++)
{
d[i][j] = 0.123456789;
e[i][j] = 0.123456789;
}
for(a=0;a<100000;a++)
{
for (i=0;i<100;i++)
for(j=0;j<100;j++)
{
d[i][j] = d[i][j] * e[i][j];
}
}
////////////////////////////////////////////
|
|
|
|