|
Just initialize all three members:
test_struct global_obj = { 0, 10, 0 };
(That's what it's actually doing in C99, so why pretend otherwise )
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
When I try to compile the program in the URL:
How to: Marshal ANSI Strings for ADO.NET[^] there is error in command prompt:
"cl is not recognized" as an internal or external command operable program or batch file.
How to compile this program?
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
You should issue the command line form the console open by means of the Visual Studio Command Prompt . For instance, using Visual Studio 2005 , select
Start->Programs->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt menu item and then use the just appeared console window to write the command line.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Following is the simple code of my application...
#include "stdafx.h"
#include < iostream >
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Hello World!\n";
return 0;
}
The out put of this program on console is as follows:
The system cannot execute the specified program.
Press any key to continue...
Mohsin Ali
|
|
|
|
|
Are you compiling for the correct platform?
|
|
|
|
|
Hi guys,
I've been working on my Linked List implementation and have run into some troubles. There is an easy solution (more on this later) but the problem is, it's a messy solution.
When I compile my project I get the following errors:
<project name="">\LinkedTileList.h(17) : error C2061: syntax error : identifier 'Tile'
<project name="">\LinkedTileList.h(24) : error C2061: syntax error : identifier 'Tile'
<project name="">\LinkedTileList.h(26) : error C2061: syntax error : identifier 'Tile'
<project name="">\LinkedTileList.h(29) : error C2143: syntax error : missing ';' before '*'
<project name="">\LinkedTileList.h(29) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
<project name="">\LinkedTileList.h(29) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
<project name="">\LinkedTileList.h(38) : error C2061: syntax error : identifier 'Tile'
<project name="">\LinkedTileList.h(48) : error C2061: syntax error : identifier 'Tile'
<project name="">\LinkedTileList.h(59) : error C2061: syntax error : identifier 'Tile'
</project></project></project></project></project></project></project></project></project>
It doesn't recognise my Tile class from within the Node class of my linked list.
Here is LinkedTileList.h
#pragma once
#ifndef INC_LINKEDLIST_H
#define INC_LINKEDLIST_H
#include "Globals.h"
class Node;
class HeadNode;
class TailNode;
class InternalNode;
class Node
{
public:
Node();
virtual ~Node();
virtual Node * Insert(Tile * theTile)=0;
private:
};
class InternalNode: public Node
{
public:
InternalNode(Tile * theTile, Node * next);
virtual ~InternalNode();
virtual Node * Insert(Tile * theTile);
private:
Tile * myTile;
Node * myNext;
};
class TailNode : public Node
{
public:
TailNode();
virtual ~TailNode();
virtual Node * Insert(Tile * theTile);
private:
};
class HeadNode : public Node
{
public:
HeadNode();
virtual ~HeadNode();
virtual Node * Insert(Tile * theTile);
private:
Node * myNext;
};
class LinkedTileList
{
public:
LinkedTileList();
~LinkedTileList();
void Insert(Tile * theTile);
private:
HeadNode * myHead;
};
#endif
LinkedTileList.cpp
#include "Globals.h"
#include "LinkedTileList.h"
InternalNode::InternalNode(Tile * theTile, Node * next):
myTile(theTile), myNext(next)
{
}
InternalNode::~InternalNode()
{
delete myNext; delete myTile;
}
Node * InternalNode::Insert(Tile * theTile)
{
myNext = myNext->Insert(theTile);
return this;
}
Node * TailNode::Insert(Tile * theTile)
{
InternalNode * dataNode = new InternalNode(theTile, this);
return dataNode;
}
HeadNode::HeadNode()
{
myNext = new TailNode;
}
HeadNode::~HeadNode()
{
delete myNext;
}
Node * HeadNode::Insert(Tile * theTile)
{
myNext = myNext->Insert(theTile);
return this;
}
LinkedTileList::LinkedTileList()
{
myHead = new HeadNode;
}
LinkedTileList::~LinkedTileList()
{
delete myHead;
}
void LinkedTileList::Insert(Tile * pTile)
{
myHead->Insert(pTile);
}
Tile.h
#pragma once
#ifndef INC_TILE_H
#define INC_TILE_H
#include "Globals.h"
static int NumTiles = 0;
static int * p_iNumTiles = &NumTiles;
class Tile
{
public:
Tile(void);
~Tile(void);
float GetLeft(void);
float GetTop(void);
void SetLeft(float);
void SetTop(float);
private:
float left;
float top;
};
#endif
Tile.cpp
#include "Tile.h"
Tile::Tile(void)
{
*p_iNumTiles++;
}
Tile::~Tile(void)
{
*p_iNumTiles--;
}
float Tile::GetLeft(void)
{
return left;
}
float Tile::GetTop(void)
{
return top;
}
void Tile::SetLeft(float x)
{
float * p_left = &this->left;
*p_left = x;
}
void Tile::SetTop(float y)
{
float * p_top = &this->top;
*p_top = y;
}
Globals.h is pretty much my implementation of stdafx.h . It contains all header files for the project.
Now, for the "dirty" solution - all I have to do is cut the contents of Tile.h into the beginning of LinkedTileList.h and Tile.cpp into the beginning of LinkedTileList.cpp but you can probably tell why this feels dirty. The Tile class is used elsewhere in the project and I don't want to be making it so much a part of the LinkedTileList class, but just a resource that is available to it. Why isn't the preprocessor doing it's job? (And if it is doing it's job and I'm the one who stuffed up, then what am I doing wrong?)
Both the linked list and the tile class are far from finished but I can't go much further until I work out this problem.
|
|
|
|
|
Hi,
my C++ is very rusty but I assume this would solve it:
your LinkedTileList.h needs to know what Tile is, so it should include Tile.h
And you should use a conditional on INC_TILE_H to prevent multiple inclusion.
Hope this helps.
|
|
|
|
|
Globals.h #include 's Tile.h . I also have inclusion guards in ALL my header files.
I've tried including just Tile.h (as the LinkedTileList doesn't actually need anything else from Globals.h but this didn't help either.
Also I forgot to add before that when I cut and paste the contents of Tile.h into LinkedTileList.h and the contents of Tile.cpp into LinkedTileList.h that I get Linker errors. I assume these would be the same errors that exist if I were to find a "cleaner" way of solving these errors. The linker errors are:
1>LinkedTileList.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall Node::~Node(void)" (??1Node@@UAE@XZ)
1>LinkedTileList.obj : error LNK2001: unresolved external symbol "public: __thiscall Node::Node(void)" (??0Node@@QAE@XZ)
1>LinkedTileList.obj : error LNK2001: unresolved external symbol "public: __thiscall TailNode::TailNode(void)" (??0TailNode@@QAE@XZ)
Perhaps they can help in diagnosing the issue.
|
|
|
|
|
Hi,
you should not move around code; organize your .cpp files the way you see fit.
Provide .h files that go with them.
have each .cpp file include its own .h file
And make sure all .h files include whatever other .h files are required (so they know the types
and constants they need to know)
Then compile.
If there are errors, the first strategy to try is: work on the first error that shows, until it is
gone. Then iterate, until there are no more errors.
|
|
|
|
|
Those errors mean that you didn't provide a body for the constructor and destructor of the Node class and for the constructor of TailNode. You only specifed a prototype, but no definition of the function. Add a { } after those functions to fix that (this provides an empty function definition).
|
|
|
|
|
Thanks Cedric,
I added a forward declaration for the Tile class in LinkedTileList.h and this solved the compile errors. I then followed your suggestions to fix the linker errors.
Thanks for your help, you're quite the helpful one
|
|
|
|
|
I don't know why but in the release version of my program I get DOUBLE selections (blue line (FULLROWSELECTION is set)); Yet I don't get the error in Debug version. Anyone had simular experience in VS2008 MFC?
A C++ programming language novice, but striving to learn
|
|
|
|
|
Hi,
it could be all kinds of things.
This[^]
might shed some light on your problem.
|
|
|
|
|
The problem is that the list control selects the very first item as well as the item you have selected. It does not do this in debug!, only Release version. Both versions are the same; only you select to compile "release" from the "debug" previous version. The code is the same.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Hi,
without seeing all relevant code, chances are slim anyone can help you. However, here are two hints
that may or may not apply.
1.
Larry Mills Sr wrote: The code is the same.
Even when the source file remains unchanged, its semantics may change, e.g. the meaning
of debug(), trace(), assert() may change, or some of your code may depend on a #defined symbol
(such as _DEBUG or so) resulting in some side-effect no longer being present, as in (I admit
it is an extreme example): assert(x=1);
in debug, this would set x to 1 and check for non-zero,
in release, this would do nothing at all, i.e. leave x unchanged.
Obviously what was meant is assert(x==1); which does not change a thing, whether debug or release.
2.
Several controls fire their "SelectionChanged" event more than once, e.g. when clicking an item,
they first report the loss of the old selection, then the new selection. This behavior often gets
overlooked.
|
|
|
|
|
Thanks, I think I fixed it though. On that particular List Control I forgot to set "Single Selection" to TRUE. But really I don't think it was supposed to do the other anyway. Anyway, it hasn't done the double selection in Release since I set it to single selection.
Thanks for your response.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Is using CreateFileMapping/MapViewOfFile functions means sharing "Memory" or "File" on the disk?
I compiled that code for both
-INVALID_HANDLE_VALUE, // use paging file (that is on the disk)
and
-"C:\\a.txt" //physical file too.
All of them works. And second process can show "Message from first process".
The second process calls:
1-) OpenFileMapping to get handle
2-) MapViewOfFile.
What is happening here?
Does
second process get handle to physical "file" which is on the disk and get "Message from first process" string which is written by first process to file.
or
Second process get handle to first process' physical "memory" and get string from its address space?
Are they communicating with writing/reading same file(pagefile or another file) on the disk or same memory?
Msdn Documentation which is about procedure for sharing data with CreateFileMapping/MapViewOfFile/OpenFileMapping is confused me.
Thanks.
|
|
|
|
|
The FileMapping stuff, when used by two processes on the same machine, is really sharing memory;
it optionally uses a file as a backup or for persistency if you indicated that is what you want.
I have used it once, for high-performance interprocess communication and it worked very well,
much faster than straightforward file sharing would.
|
|
|
|
|
Hi
CreateFileMapping/MapViewOfFile is usually used in IPC(inter process communication)
When you modify any particaluar file and want to be notified of the same in another application which do not drectly access the file , this is the mechmanism you would use.
The second process would get the handle to first process physical memeory that is the reason you need to use critical section.
Here there is only one copy of the file and when there is some change in the data then you could SENDMESSAGE WM_COPYDATA which also be received in the other application and thus there will be notifiaction of the data sent.
I hope it answers your question.
|
|
|
|
|
Hi,
I'm using VC++ 6.0 and new to MFC.
How do I draw on to desktop instead of drawing into the application's window?
How do I set the DC to desktop window's dc.
Thanks in advance.
Regards,
sanju.
|
|
|
|
|
HDC hdc = ::GetDC(NULL);
CDC dc = CDC::FromHandle(hdc);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
(1.)
In TreeCtrl if i check the checkbox of parent node than its childs are automatically selected.
Can ,This is possible in opposite condition,means if i select the check box of all childs than the check box of its parent is automatically selected.
(2.)
In Tree ctrl i want if the check box of parent is not checked,so the childs of this parent are not expand.
Please tell me with example.
Thanks in advance.
I m awaiting for your valuable suggestion.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
the check box is user defined?
|
|
|
|
|
It is a one property of TreeCtrl.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
in tab control i have three tabs
i want to create dialog on tab click
and want to enddialog which is already created
how can i check which dialog was created which shoud end now
|
|
|
|