|
Xpnctoc wrote: the compiler still has to convert a sizeof call into a useable via some kind of library.
No it merely calculates the size of the operand and puts the resulting value in the object code. There is no associated library call because sizeof() is an operator, just like + .
Xpnctoc wrote: If they had a truly informative error message
I think this rant should be directed at Microsoft.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: No it merely calculates the size of the operand and puts the resulting value in the object code. There is no associated library call because sizeof() is an operator, just like +.
And yet other operators like + and == are fully accessible within the Immediate window. You said it yourself... there is no associated library because sizeof is an operator. How can any operator -- an integral part of the language -- ever be out of scope? I mean, wouldn't it strike you as really messed up if suddenly you got an error message saying + was "out of scope"?
If 'sizeof' is only evaluated at compile time and treated as a constant in the executable, and Immediate cannot access it as part of the available evaluation syntax, then it seems to me 'sizeof' would be better termed as a MACRO than an operator -- just like using the #define precompiler directive.
|
|
|
|
|
Well, you are right in all you say and I am (partly) wrong. My biggest mistake was to take your query at face value, rather than checking what results I get. I have just tested this by adding sizeof(variable) in my watch window while debugging and it shows the correct value. So, we go back to the original problem that you are seeing: where exactly, and under what conditions, are you typing your query?
It's time for a new signature.
|
|
|
|
|
The actual query I'm using is what I originally listed:
? sizeof(bool)
rather than
? sizeof(boolean_variable)
To reproduce what I'm getting:
1. Make a new project: C++, CLR, Windows Forms Application
2. Double-click the form to generate the Form_Load event.
3. Put a break point on the closing brace of the Form_Load event handler method.
4. Run the application.
5. When the break point is hit, bring up the Immediate window and type "? sizeof(bool)" (without the quotes, of course)
6. Result is: "error: identifier 'sizeof' is out of scope"
If you take identical steps but use a C# project, you will get an output of "1". Michel had mentioned that we should expect the error message in unmanaged C++, but from the steps I've outlined above, we're not dealing with unmanaged C++. We're dealing with CLR-aware C++, so it seems to me we should have the same .NET support as C#.
BTW, this is under VS 2008 (and Windows 7 64-bit if that makes a difference).
|
|
|
|
|
OK, I can reproduce this under VS2010 (full and Express versions). I guess the only way forward is to raise this with Microsoft. I'm still confused as to why this happens with managed but not unmanaged code; I guess two different debuggers.
It's time for a new signature.
|
|
|
|
|
Hi all, could any one help me out of this
I just want to include a logo.jpg file in my .exe file. I have tried using Image Class (System.Drawing) in Visual C++, but after opening the .exe, and when tried to print, an error is popping up indicating the logo.jpg is missing, it is successful only after including the logo.jpg in the folder.
private: System::Void printDocument_PrintPage(System::Object^ sender, System::Drawing::Printing::PrintPageEventArgs^ e)<br />
{<br />
Image^ newImage = Image::FromFile( "logo.jpg" );<br />
e->Graphics->DrawImage( newImage, 605, 70, 150, 100 );<br />
}
I want to know, is there any other method of including the logo to my print page, which doesn't need a logo.jpg file to be included in the respective folder
Any help is appreciated...Thanks
|
|
|
|
|
this is msdn link[^] what are you looknig for, you can also google for "visual studio resource resx"
...if you are using "visual c++" or "visual c#" this is made so easy by using the designer
|
|
|
|
|
Hi, I'm not very experienced with managed C++(.Net 1.1). So I am having a possibly simple problem with memory management. Below is the code for my question:
<code>
SomeFunction()
{
unsigned char temp __gc[] = new unsigned char __gc[count];
myObject->setArray(temp);
}
void setArray(ByteArrayType arr)
{
this->byteArray = arr;
}
</code>
The problem is, memory consumption increases at the above specified point, and it never decreases, causing an outofmemory exception later. I don't understand. Isn't "temp" supposed to be garbage collected? it is not referenced elsewhere. I have to use arrays for implementation.
Thanks in advance
|
|
|
|
|
|
what the "ListView_DeleteColumn" function do? it's not a .net function...so write the code here if you want an answer
|
|
|
|
|
This is driving me up the wall so I hope someone can help
I have an existing Native C++ DLL created in visual studio 2008.
I want to use some of the class's and the functionality that they provide from within a C++/CLI project (wrapper DLL) which in turn can be used from other .NET applications so in affect I will have a .NET application which references a C++/CLI dll which in turn references a native C++ dll
I can create each of the components as separate protects within a single VS2008 solution file and everything builds without error.
The .NET application runs without error and is able to instantiate the C++/CLI object that I have without error. The problem occurs when I call a method on the C++/CLI object which in turn instantiates a native class. I can debug the code right to the point where:
NativeObject no = new NativeObject();
is called at which point I get a 'System.Runtime.InteropServices.SEHException' occurred in .dll'
The native code works fine used within other native projects the problems only occur in this .NET environment.
For reference I'm exporting class definitions from the native DLL using this at the top of the .h file
#ifdef EXPORT_IMS_CORE_CLASS
#define IMS_CORE_CLASS_API __declspec( dllexport )
#else
#define IMS_CORE_CLASS_API __declspec( dllimport )
#pragma message( "Automatic link to IMSCore.lib (IMS::DataTypes::DataObject)" )
#pragma comment( lib, "IMSCore.lib" )
#endif
I can supply a cut down solution where the error occurs if any one wants to have a look
Thanks in advance for any help, Simon
modified on Wednesday, May 5, 2010 9:17 AM
|
|
|
|
|
I would check my trust model. You will need full trust to do this.
|
|
|
|
|
Hi
The trust settings appear to be ok
I can supply a cut down solution where the error occurs if you want to have a look
|
|
|
|
|
Please don't post the same questions here AND in QA
|
|
|
|
|
hi
i want to run an dshow an application in my project and limit it to my MDI form !
can i do it? if yes how can i?
|
|
|
|
|
I think you should write hWnd of MDI form in dshow owner device.
|
|
|
|
|
Well, I'm new to C++ and I think I'm missing something obvious. I'm trying to create a text label control on a form, but I want the actual text to be dynamic (I want to use a variable that I can change on-the-fly).
So where I'd normally have something like this:
this->labelDynamicText->Name = L"labelDynamicText";
this->labelDynamicText->Size = System::Drawing::Size(145, 34);
this->labelDynamicText->TabIndex = 5;
this->labelDynamicText->Text = L"This is some dynamic text";
I was thinking of something like this:
this->labelDynamicText->Name = L"labelDynamicText";
this->labelDynamicText->Size = System::Drawing::Size(145, 34);
this->labelDynamicText->TabIndex = 5;
this->labelDynamicText->Text = MyDynamicText;
and I'd be able to something like:
int intCount = 0
Do Until [intCount = 60]
MyDynamicText = "this text sits on the screen for a few seconds"
intCount = intCount + 1
Loop
MyDynamicText = "this text displays after 60 seconds"
So can anyone help guide me in the right direction? Can I easily do this, and where do I start? Thanks in advance!
|
|
|
|
|
Off topic: Please use <pre></pre> tags around your code (use the code block button above) rather than bolding.
On topic : Changing the contents of your MyDynamicText variable does not force it to refresh the label on your form. You also need to resend it to this->labelDynamicText->Text as was done in the initialisation. Note also that your counter will run very fast rather than taking 60 seconds, you probably need to use a timer or sleep() call.
It's time for a new signature.
|
|
|
|
|
I had developed RTSP/RTP server for mp3(audio) which is working fine.
Now I am enhanceing server for MPEG1/2 Video streaming.
In vedio streaming I need to calculate "Video RTP Packet Timestamp field"
I did'n found any proper document for Timestamp calculation.
If anybody have any idea regarding this,please reply me.
Thanks in advance.
Vijay
|
|
|
|
|
Hi,
I'm trying to write a binary file, using BinaryWriter. My code does write a file, but it is empty. This is the code I'm using:
FileStream^ fs = gcnew FileStream(Convert::ToString(fileName), FileMode::Create);
BinaryWriter^ w = gcnew BinaryWriter(fs);
int rows = fileData->GetLength(0);
int cols = fileData->GetLength(1);
try
{
for (int row = 0; row < rows; row++){
for (int col = 0; col < cols; col++){
w->Write(fileData[row,col]);
}
}
}
finally
{
w->Close();
fs->Close();
}
Does anyone have a clue why the written files is empty?
Thanks!
|
|
|
|
|
I forgot to mention that fileData is an array<String^,2>^
|
|
|
|
|
Try running it in the debugger to check that you actually have some data and that it is being written to your file.
It's time for a new signature.
|
|
|
|
|
Thanks for your answer Richard. I tried running in the debugger. I do have some data to write to the file. How can I check whether it is actually written to the file? When I check the file in Windows Explorer it stays at 0kb.
|
|
|
|
|
I don't know what is happening with your file, I just tried a similar test and the file was written correctly. All I can suggest is that you step through your program to ensure the values actually get written, and also that no other part of your program destroys the file.
It's time for a new signature.
|
|
|
|
|
That's strange. I'll try it on another computer, maybe that helps.
Thanks a lot for your help anyway!
|
|
|
|