|
Hi Mark,
no we are not colonizing the C++/CLI forum ; I just copied and improved two lines
of code from the OP and introduced some .NET stuff that exists for all CLR
languages AFAIK.
If, however I had known at that time that the identical question was posted
in the C# forum, I would have answered it there (identically). As it is, I told him
overthere not to duplicate stuff...
Please feel free to adjust whatever I may have messed up language wise.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks a lot for the reply.
I will try and see if it works.
|
|
|
|
|
Sometimes I have to allocate more than 500 MB of data. In such situations I run into OutOfMemoryException.
The real problem here is a third party API I am using expects string as an input parameter which can sometimes be as large as 800 MB.
That why I am using HeapAlloc. HeapAlloc has worked fine for me so far without any problems.
|
|
|
|
|
OK
I hope you don't forget to release that memory eventually...
You probably should make a managed object that allocates, pins, provides the
pointer, and has a Dispose/finalizer/destructor to make sure it gets freed too.
You might want to look at the LP_Pinner class in my TrayIconBuster article.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I do a HeapFree everytime. Actually I am running this on a Grid environment with 1000's of items and each item is memory intensive and each item sometimes goes beyond 1.5 GB. But after every run the memory comes back to 60 mb or so.
I will try whatever you said.
Thanks again for all the valuable information.
|
|
|
|
|
This is purely a guess on my part, but perhaps you might consider using VirtualAlloc instead of HeapAlloc ?
Maybe the VirtualAlloc will be able to provide all the memory you need without OutOfMemory exceptions.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
1. I am writing a program to access parallel port in Windows XP.
2. taking help from net i found a program called UserPort which opens ports.
3. Using a small program in C using stdio and conio include files i could access the port.
4. However the problem is i have to write code in C++ and when i try to compile the same code in C++ as a .cpp file the compiler gives an error saying "_outp undeclared " and " sleep undeclared". the sme code compiles properly in c using same IDE.
5. I am using Dev-C++ 4.9.9.2. I cant use any other compiler.
6. My code is given below as a c file
/*********************************************
binary counter : This will count from 0 to 255 This takes printer port address as 0x378 and pauses for 250 mS between every count
**********************************************/
#include <stdio.h>
#include <conio.h> /*required for _outp*/
int main()
{
int x;
for(x = 0;x<=255;x++)
{
_outp(0x378,x);
sleep(250);
}
return 0;
}
7. Pl help. Its urgent.
Shaleen Singh
-- modified at 14:44 Wednesday 15th August, 2007
|
|
|
|
|
I'm not sure why you'd post this on a Managed Visual C++ message board.
In Visual C++, the CRT function _outp() is declared in <conio.h>
I can't see what header files you've included in your code.
There's a Sleep() (with a capital S) Windows API
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: I'm not sure why you'd post this on a Managed Visual C++ message board.
Liar
|
|
|
|
|
|
Hi
I don't know the answer to Shaleen's question but I have a question of my own.
1. I'm also writing a program for parallel port communication in Win XP. I've used the code in http://www.codeproject.com/system/AsefPortAccess.asp as a guideline.
2. When running the program, the line "_outp(0x378, iByte);" gives an error. On debugging I tracked the error to the assembly code line "1022CC4B out dx,al" which gives the error "Unhandled exception in ParallelComm.exe (MSVCRTD.DLL): 0xC0000096: Privileged Instruction."
I'd appreciate it if someone could help me out here
mirispearl
|
|
|
|
|
hi,
when I tried to compile the following simple C++ program,
#include<iostream.h>
main()
{
cout << "Hello World!";
return 0;
}
got the error as
In file included from /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/backward/iostream.h:31,
from hello.cpp:1:
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
/tmp/cc3RakqC.o(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/tmp/cc3RakqC.o(.text+0x60): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/cc3RakqC.o(.text+0x9d): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/cc3RakqC.o(.text+0xc8): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/cc3RakqC.o(.text+0x121): In function `main':
: undefined reference to `std::cout'
/tmp/cc3RakqC.o(.text+0x126): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc3RakqC.o(.text+0x152): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/tmp/cc3RakqC.o(.text+0x181): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/tmp/cc3RakqC.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
I am using cc hello.cpp to compile the program
When I tried with the command g++ hello.cpp,got the message
In file included from /usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/backward/iostream.h:31,
from hello.cpp:1:
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
After using g++ hello.cpp for compilation,I ran a.out to see the output,but I got '-bash: a.out: command not found' error.
Please help me out in compiling this.
Regards,
Vasudha
|
|
|
|
|
First of all, you are in the wrong forum. Please ask this type of question in the C++ forum not the C++/CLI (Managed C++) one. I believe you need to use: #include <iostream> rather than #include <iostream.h> , which is deprecated, as the error message suggests. Also, cout is found in the std namespace.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
There was discussion with my fried about inheritance. He argued with me that inheritance is not for reuse. He is telling that inheritance is for extendibility and specialization. But I may books it is referred that inheritance is for reuse.
So I like some experts to explain this in details.
When I go ogled I got both the answer that is some people are telling that is for reuse, while others are telling that, it is for specialization and expandability.
Thanks in advance,
Nandu
|
|
|
|
|
Hi,
it depends on your definition of reuse.
1.
if you copy-and-paste some code from app1 to app2, are you reusing it ?
2.
if you need some class, and later on you create a more specialized class using
inheritance because you actually need both classes, then you are specializing,
expanding and reusing at the same time. Here reuse means the specialized class
is inheriting existing code that it does not contain itself.
3.
if you have app1 with class1 and app2 with class2, and then discover a lot of code
if common to both class1 and class2, you may be able to come up with a new
class0 that is to contain the common parts, then have class1 and class2 inherit
from it. So you reuse the common code from class1 and class2 by removing it and
inserting it in class0. class0 being more general than both class1 and class2,
has a better probability of being reused-as-is in a later app3.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Same thought Luc Pattyn , but for the above answer his reply is why derive from that class0, instead we can create a object of class0 and call its methods in calss1 or calss2.
nandu
|
|
|
|
|
Nandu_77b wrote: He argued with me that inheritance is not for reuse
Don't argue with idiots. They will just drag you down to their level and beat you with experience.
|
|
|
|
|
led mike wrote: Don't argue with idiots. They will just drag you down to their level and beat you with experience.
And I have the scars to prove it.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George,
Can you please give me some proves.
Thanks
Nandu
|
|
|
|
|
Nandu_77b wrote: Can you please give me some proves.
You mean like this[^]
If I were you I would report to my ISP that Google doesn't work. I would not put up with paying for internet access that doesn't include the most powerful internet tool today.
|
|
|
|
|
Hi All,
From the above discussion we can conclude that INHERETANCE is for both code reuse and specialization as well.
If any one don’t agree with this please ..raise the concerns.
Thanks,
Nandu.
|
|
|
|
|
Hello, i need to creat an array or matrix of short (16 bit) from matrix of integer (32 bit) where all the members of the int matrix are not bigger then short, i mean we will not have a problem. the problem is that i need to do it fast because i have a real time software and i dont want to just loop and copy from all members of array...
could anyone help?
|
|
|
|
|
Hi,
1.
you can't convert a matrix the way you want without looking at all the values.
2.
an array of shorts is smaller than an array of ints (it takes half the amount
of memory or disk space, needs half the time to transmit, etc); it is not
necessarily faster though, since all computations normally use int anyway.
3.
more contextual information might result in better answers.
What is it you want to do ?
How big if the array ? (and how many are there)
What is real-time ? How much time are you willing to spend ?
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Why are you writing real-time software in C++/CLI?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|