|
Then where I would have posted this?
Sushant Duggal.
|
|
|
|
|
Managed C++/CLI is the forum for discussion of .NET C++, as it clearly states. This[^] is the general C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
The ++ operator occurs in both languages AFTER x is given it's final <BR>value. The difference is that in Java, the values are by reference, so <BR>the value that x is assigned to, is the value that still has a ++ operator outstanding. so, x gets set to 18. y gets incremented, to 7,<BR> and x also gets incremented, but it's the same x that is 18, not a <BR>copy of x which is 16.
I can understand that in java, the values are by reference. that means X is incremented direectly where it is stored, it sets it to 12 + 6 = 18.
Confusion ..... when the X is going to incremented? and why it is not reflected(X's value is still 18).
Thanks For your Patience,
Sushant Duggal.
-- modified at 3:39 Thursday 28th September, 2006
Sushant Duggal.
|
|
|
|
|
The statement i = i++ has undefined behavior in C++ and different compilers can generate different code and still be standards compliant. The = operator does not define a separate sequence point, and C/C++ rules dictate that an expression can modify an object's value only once within a single sequence point - else the compiler's free to interpret the code in whatever way it wants to.
|
|
|
|
|
Hi All,
I was trying to explore the working of double Linklist in MFC using CList.
I have created a struct such as
struct XXXX{
char buff[10];
char buff1[10];
}YYY;
then
CList <YYY,YYY&>my_list;
my_list.AddHead();
This is working fine . But my problem is when i want do ...
struct zzzz{
char buff[10];
char buff1[10];
}PPP;
struct XXXX{
CList<PPP,PPP&>my_second_Struct;
char buff[10];
char buff1[10];
}YYY;
Is it help me to achive my goal. If Not please help me
Regards &Thanks
Neeraj Kumar Jha
|
|
|
|
|
My overall advice is that you'd do better to learn to use the stl::list instead of the MFC one. Either way, which ever you use, it's not a managed C++ construct, so you're in the wrong forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hey...........
i managed to compile and run a C++ program that intializes and reads/writes to a serial port . I was using the Dev C++ compiler to write the code.
Now I am trying to verify the output.What I did was to write the letter 'a' to the serial port. The serial port is connected to a digital oscilloscope and I intend to see the voltage patterns that correspond to the letter 'a' as below.
11 01000001 0 = stop bits / data bits / start bit
But this voltage pattern is not shown in the oscilloscope. Instead I only see the handshaking signal (a data bit '1') coming from the serial port.( I was able to see the handshaking control signal/initializing signal but not the data signal (the data signal was the letter 'a') ).
I saw a '1' from pin 3 and pin 6 of the R232 serial port when I ran the program. These pins correspond to Transmit data, Data set ready signals that are sent from the laptop to the oscilloscope.
1. I cannot see any data signals corresponding to the letter 'a'. What is the reason behind this????
Is it because there is no reply from the oscilloscope for the handshaking signal the laptop sends to it?? (i am using a laptop to run the program)
(Meaning the oscilloscope fails to send a handshking signal back to the laptop......this might indeed be the case because oscilloscopes are not built to send handshking signals)
2.If so how can I bypass sending handshking signals and simply send the letter 'a' to the oscilloscope and view its voltage pattern???
3.Can I do this by a simple adjustemnt to the code I have written below????
I would greatly appreciate any help u guys can give....
the code is below (compiles without errors on Dev C++ )
Serial.h
CODE
CODE// Flow control flags
#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04
// ascii definitions
#include <stdio.h>
#include <time.h>
//#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <string.h>
#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13
HANDLE SerialInit(char*, int);
char SerialGetc(HANDLE*);
void SerialPutc(HANDLE*, char);
--------------------------------------------------------------------------
Serial.cpp
CODE
CODE
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <time.h>
#include <windows.h>
#include <string.h>
#include "serial.h"
// Flow control flags
#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04
// ascii definitions
#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13
using namespace std;
// variables used with the com port
BOOL bPortReady;
DCB dcb;
COMMTIMEOUTS CommTimeouts;
BOOL bWriteRC;
BOOL bReadRC;
DWORD iBytesWritten;
DWORD iBytesRead;
HANDLE SerialInit(char *ComPortName, int BaudRate)
{
HANDLE hCom;
hCom = CreateFile(ComPortName,
GENERIC_READ | GENERIC_WRITE,
0, // exclusive access
NULL, // no security
OPEN_EXISTING,
0, // no overlapped I/O
NULL); // null template
bPortReady = SetupComm(hCom, 2, 128); // set buffer sizes
bPortReady = GetCommState(hCom, &dcb);
dcb.BaudRate = BaudRate;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
// dcb.Parity = EVENPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fAbortOnError = TRUE;
// set XON/XOFF
dcb.fOutX = FALSE; // XON/XOFF off for transmit
dcb.fInX = FALSE; // XON/XOFF off for receive
// set RTSCTS
dcb.fOutxCtsFlow = TRUE; // turn on CTS flow control
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; //
// set DSRDTR
dcb.fOutxDsrFlow = FALSE; // turn on DSR flow control
dcb.fDtrControl = DTR_CONTROL_ENABLE; //
// dcb.fDtrControl = DTR_CONTROL_DISABLE; //
// dcb.fDtrControl = DTR_CONTROL_HANDSHAKE; //
bPortReady = SetCommState(hCom, &dcb);
// Communication timeouts are optional
bPortReady = GetCommTimeouts (hCom, &CommTimeouts);
CommTimeouts.ReadIntervalTimeout = 5000;
CommTimeouts.ReadTotalTimeoutConstant = 5000;
CommTimeouts.ReadTotalTimeoutMultiplier = 1000;
CommTimeouts.WriteTotalTimeoutConstant = 5000;
CommTimeouts.WriteTotalTimeoutMultiplier = 1000;
bPortReady = SetCommTimeouts (hCom, &CommTimeouts);
return hCom;
}
char SerialGetc(HANDLE *hCom)
{
char rxchar;
BOOL bReadRC;
static DWORD iBytesRead;
bReadRC = ReadFile(*hCom, &rxchar, 1, &iBytesRead, NULL);
return rxchar;
}
void SerialPutc(HANDLE *hCom, char txchar)
{
BOOL bWriteRC;
static DWORD iBytesWritten;
bWriteRC = WriteFile(*hCom, &txchar, 1, &iBytesWritten,NULL);
return;
}
int main()
{
HANDLE my=SerialInit("com1",1200);
char letter;
HANDLE *ptr;
*ptr=my;
SerialPutc(ptr,'a');
//letter=SerialGetc(ptr);
getch();
return 0;
}
hi
|
|
|
|
|
prashw wrote: I was using the Dev C++ compiler to write the code.
This probably decreases the odds that you meant to post this in the C++/CLI forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hmm ..then what is the appropriate forum in this site that I should pose the question??? Appreciate your help
hi
|
|
|
|
|
The C++[^] forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi,
Is it possible to create OCX in borlands c++?
if so help me out the way how to do it with an example code snippet
thanx in advance,
zari
|
|
|
|
|
Do you want to write an OCX using .NET, or have you posted in the wrong forum ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I am new to borlands c++, what i want to know is that any possibility available in borlands c++ to create an OCX component as similar to that of vc++
if theres a possibility how???
zari
|
|
|
|
|
The two pertinent questions are:
1 - why are you asking this in the managed c++ forum and not the Visual C++ forum ?
2 - why are you asking it on a site that is 'your Visual Studo and .NET homepage' ? You MAY find some people here who use Borland, but it won't be very many.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sorry for the mistake i have done
Tot i can get a solution here.
zari
|
|
|
|
|
I have a VS2005 solution that includes a number of unmanaged c++ library projects, a managed c++ library project that wraps some classes from the unmanaged projects and a c# client project.
I can debug the c# project and step into the managed c++ project but I cant step from there into the unmanaged c++ projects. Anyone know if this should be possible and how I can get it to work?
|
|
|
|
|
Never tried that but my first thought is have you checked the "Enable Debuggers/Enable unmanged code" check box in the project/debug settings?
"When your argument falls apart...resort to name-calling." Red Stateler aka (D)espeir in the Soapbox
Whereas "liberal" is just a moron. Red Stateler aka (D)espeir in the Soapbox
led mike
|
|
|
|
|
led mike wrote: Never tried that but my first thought is have you checked the "Enable Debuggers/Enable unmanged code" check box in the project/debug settings?
Worked a treat thank you
|
|
|
|
|
Hello,
I need to use COM server in VC++.NET 2003 managed code. After using Tlbimp.exe to generate runtime callable wrapper I can use operator new to create instance of MyClass. What do I need to do to query another COM interface from this instance? In regular unmanaged code I just need to call ::CoCreateInstance(…) and QueryInterface(…). What do I need to call in managed code instead?
Please help!!!
Regards,
Leonid
|
|
|
|
|
lafleon wrote: What do I need to do to query another COM interface from this instance?
Can you just call QueryInterface on the instance or can you cast the pointer you got back from the new operator?
|
|
|
|
|
It’s my question. Do you have any code samples?
Regards,
Leonid
|
|
|
|
|
Nope, I am sugesting these are things you can try yourself
|
|
|
|
|
---CODE---
// Split Test: String::Split does NOT work properly when given a # of substrings to return
void splitTest() {
String^ toBeSplit = "a b c d e f g h";
array<String^>^ split = toBeSplit->Split(' ',3);
//Expected: "Count: 3" Actual "Count: 8"
Console::WriteLine("Count: {0}",split->Length);
}
---END CODE---
Am I doing something ridiculously stupid, or is this really a bug?
The equivilent C# code works properly.
|
|
|
|
|
jmlsteele wrote: toBeSplit->Split(' ',3);
I don't know how you got that to compile but the following works as expected
array<wchar_t>^ delim = gcnew array<wchar_t> {' '};
String^ src = "1 2 3 4 5";
array<String^>^ a1 = src->Split( delim);
Console::WriteLine( String::Format("{0}", a1->Length));
a1 = src->Split( delim, 2);
Console::WriteLine( String::Format("{0}", a1->Length));
led mike
|
|
|
|
|
I get no errors, and no warnings when compiling what I posted, and upon further inspection I realise why.
The first entry you get for intellisense is Split(... cli::array<__wchar_t,1> ^seperator) so it's just converting my 3 into a wchar_t.
Now I feel stupid...
Thanks for your help.
|
|
|
|