|
You could use an equivalent value class :-
value class MOctetString
{
unsigned int length;
array<unsigned char>^ value;
};
|
|
|
|
|
kristmun wrote: Is there a better way to copy the data into the ArrayList, and is
there a more suitable structure than a ArryList to handle binary data of different lengths?
They hide that information in the documentation[^]
led mike
|
|
|
|
|
Hi guys,
thanks for the advice.
It works now using the Copy method
<br />
array<unsigned char>^ value = {'a','b','c'};<br />
char* ptr = new char[value->Length];<br />
Marshal::Copy(value,0,(IntPtr)ptr,value->Length);<br />
and the other way around
<br />
int length = 3;<br />
char str[] = {'d','e','f'};<br />
char* pStr = &str[0];<br />
array<unsigned char>^ strArr = gcnew array<unsigned char>(length);<br />
Marshal::Copy((IntPtr)pStr,strArr,0,length);<br />
I didn't quite get the value class way
|
|
|
|
|
Hi All,
My application doesnt compile if I use anything from namespace std. I have tried "using namespace std" and std::
Can anyone tell me what the problem could be?
Extremely sorry for asking a basic question. I am just a starter. Hope you all understand.
Thanks and Regards,
Anil
|
|
|
|
|
When you say it doesn't compile, what is the error ?
Did you #include what you're trying to use ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
Now the previous error disappeared. But I still get
error C2079: 'Logger::m_oStream' uses undefined class 'std::basic_ofstream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
Can you please help? I am using Visual Studio .Net 2003
Thanks and Regards,
Anil
|
|
|
|
|
If you could post a minimal code snippet that reproduces the error, it'd be easier to figure otu what headers you are missing.
|
|
|
|
|
Are you including iostream ( not iostream.h ) ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
right chris.....i am including iostream.....any problem with that...??
|
|
|
|
|
No - you need to post your code for us to be able to help more.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
my .h file
#pragma once
using namespace std;
class Logger
{
public:
Logger(void);
~Logger(void);
private:
char *m_pFileName;
std::ofstream m_oStream;
public:
void LogMsg(char * functionName, char * condition);
};
cpp file
#include "StdAfx.h"
#include <iostream>
#include ".\logger.h"
Logger::Logger(void)
: m_pFileName(NULL)
{
m_pFileName = "E:\\projects\\something.log";
m_oStream.open(m_pFileName, std::ios_base::app);
}
Logger::~Logger(void)
{
}
void Logger::LogMsg(char * functionName, char * condition)
{
}
Thanks in Advance for any help....[ ]
|
|
|
|
|
Anil_vvs wrote: std::ofstream m_oStream;
std:: is a waste of time, you've put a using above it. However, if you want a member variable, the #include needs to be in the .h, not the .cpp. Alternatively, you can put it in an anonymous namespace in the cpp.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanx a lot Chris.....will try that...
|
|
|
|
|
I am getting live data with gmt time in a string. but I want to convert it to local AEDT time & store the time difference 'timediff' in a variable.
Thanks a lot in advance
|
|
|
|
|
G'day mate, you're in the wrong part of the world. Check out the C++/MFC forum.
Have a look at the time_t structure and the assosiated routines
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
hi
i am facing memory & handle problem when my application invoke IXMLDOMDocument::load(), even i have used IXMLDOMDocument::Release() each time when i load new xml file, but its continuously increasing the memory and handle usage,
your help will be greatly appreciated
Thanks & Regards
neeraj
neeraj
|
|
|
|
|
This is the C++/CLI forum. We help with Managed C++ here. If you are doing so kind of mix mode programming, you need to provide some sample code of your problem. Otherwise, you need to post your question in the C++ forum also with some sample code illustrating your problem.
|
|
|
|
|
hi all,
I have declared and defined a function as
inside example.h
static int func1(struct st1 ex1, ....);
inside example.c
static int func1(struct st1 ex1,...)<br />
{<br />
---<br />
---<br />
---<br />
}
I export these functions in test.h as:
extern int func1(struct st1 ex1,...);<br />
and inside test.c, I try to call func1
<br />
#include "test.h"<br />
int main( void )<br />
{<br />
<br />
---<br />
---<br />
struct st1 ex1;<br />
int f1;<br />
f1= func1(ex1,...);<br />
}
The compiler returns with the error: undefined reference to func1.
Can anyone help me with what is wrong? My guess is : that it is to do with static; as I have defined and declared the func1 as static inside the example.h & example.c? But I dont know how to resolve?
Thanks.
-- modified at 22:12 Monday 4th December, 2006
|
|
|
|
|
If your program is C, it can't possibly be managed C++. Try the Visual C++ forum.
I see no evidence that you've included example.h inside test.c
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
test.h contains all the exported functions from example.h and its definition is in example.c.
test.h is included in the test.c.
Isnt that correct? or should i inlcude example.h also inside test.c??
if a function is declared static, how can i use it in another fileby exporting it?
|
|
|
|
|
You simply cannot call func1 from main, if main is in another file.
That is what static is for, to prevent a function from being seen
outside its definition file.
So remove the static keyword and it will compile.
(Assuming there's no other problem )
BTW you should rather use a class member function (in this case static would be ok).
|
|
|
|
|
I have the following in a c++/cli library project
template<typename T>
public ref class BaseTemplateClass
{
public:
BaseTemplateClass()
{
}
void BaseClassFunction()
{
}
};
public ref class DerivedClass : public BaseTemplateClass<System::Int32>
{
public:
DerivedClass()
{
}
void DerivedClassFunction()
{
}
};
In My c# client if I type
DerivedClass d = new DerivedClass();
d.
The little popup window appears with the method list and it does not contain BaseClassFunction().
If I type the name manually it works fine. Any ideas why I cant see the method from the template base class in the code complettion window?
|
|
|
|
|
Metadata is not produced for template functions and template classes.
|
|
|
|
|
Thanks George,
Is there any way to overcome this? I am only using the templates in the managed c++ lib so all the classes are generated from the template at compile time.
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
http://msdn2.microsoft.com/en-gb/library/sbh15dya.aspx[^]:
<quote>The common language runtime specifically supports generics in MSIL. Because the runtime knows about generics, specific types can be substituted for generic types when referencing an assembly containing a generic type. Templates, in contrast, resolve into ordinary types at compile time and the resulting types may not be specialized in other assemblies.
There is no real solution unless you can mix generics with templates for C# and VB, or wrap the template code.
|
|
|
|