|
Could someone tell me where (in MFC "make" files ) to find the path for this help file?
After several VC++ (6.0) reloads my older application won't compile due to wrong path for afxhelp.hm and I need to change this path. New projects ( with help file option) compile and work fine.
Thanks for your help.
Vaclav
modified on Thursday, June 11, 2009 1:26 PM
|
|
|
|
|
According to this MSDN the path is located in the MAP section of the help project file[^].
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you very much for your help.
Vaclav
|
|
|
|
|
Hi all,
I have recently run into a problem I was not expecting that stands to jeopardize quite a bit of work. Within my application I have a singleton system logging object that reads from and writes to an XML file. This application also loads several DLLs which in turn also need to be able to contribute to the system log. The problem is when the DLLs try to get a pointer to the singleton they are actually creating a new instance of the object rather than referencing the one that has already been created. This creates an obvious problem with concurrent file I/O.
My question is, is there any way around this? The design of this object is such that the only interface anyone has to this object is through global macros(i.e. LOG_ERROR("error happened")), which handle accessing the singleton, meaning simply passing a pointer into the DLL at creation time is not feasible.
Any help is greatly appreciated.
Thanks,
Dustin Henry
|
|
|
|
|
Dustin Henry wrote: My question is, is there any way around this?
There must be - I've done it in apps (strangely enough, it was a logging class in my app as well!).
I also had the same issue you had (getting multiple instances) - I seem to remember the following making a difference:
- Making sure that all code implementing the singleton is implemented in .cpp files, not headers
- Using the DLL version of the C run-time
I also implemented the thing as a monostate object - all methods were static, something like:
class Logger
{
public:
static void Log(std::string const& msg);
private:
Logger();
static Logger* instance_;
std::ostream& output;
};
You could then access the logger using
Logger::Log("Hello World");
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hey Stuart, thanks for your help. I still couldn't get it to work so I just ended up passing in a pointer to the already created object and setting it via a macro. Not as clean as I would like but functional.
Dustin
|
|
|
|
|
I went back and had a look at the reporting implementation I wrote - I think the main difference is that I put my logger in a DLL, not the EXE. That way it's a lot easier for everything to link against it and be able to call it at run-time.
However, the implementation boiled down to what I described - there's a class with a single static function allowing reporting, and purely static (i.e. single instance for the whole class) data members:
Header file:
class Reporter
{
public:
Reporter();
static void Report(TMessageLevel level, const std::string& message);
static bool Reporting(TMessageLevel level);
private:
static TMessageLevel level_;
static implementation-defined message_;
enum { ReportLevelCount = sizeof(Reporter::level_) * 8 };
};
C++ file:
Reporter::Reporter()
{
}
void Reporter::Report(TMessageLevel level, const std::string& message)
{
if (Reporting(level)) {
message_(message);
}
}
bool Reporter::Reporting(TMessageLevel level)
{
int levelMask = (level < ReportLevelCount)?(1<<level):0;
return (level_ & levelMask) && !message_.empty();
}
message_ is effectively a function object that allows me to hook up the output mechanism at runtime.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I created a form application
File->New->Project->VC++->Windows Form Application.
I created couple of .Cpp files and .h files.
I have structure defined in .h file
typedef struct _PHB_ENTRY
{
unsigned char name[30];
unsigned char add[50];
int checksum;
int lenght;
int reserverd1;
int reserved2;
} PHB_ENTRY;
I have declared a variable in .cpp file, which is nothing but a 'C' code.
PHB_ENTRY myEntry[50];
First i have init function, thought to initialize the struc with null, so i used memset
memset(myEntry,NULL,50);
Problem no #1: I cant see index 0 is intialized to NULL !
then i started initializing the struct
strcpy((char*)myEntry[1].name,"STEFY");
Probmelem no #2: I can see STEFY being copied from myEntry[1].name[4], first for bytes are empty , that is myEntry[1].name[0]...myEntry[1].name[3] are empty!!
i assigned other values.
myEntry[1].checksum = 13;
myEntry[2].length = 4;
Problem no: #3: I see 13 is getting updated in myEntry[1].resevered1 variable and i cant see myEntry[2].length getting updated!
can some one help me out on this strange problem?!
Just a simple C code though!!!
|
|
|
|
|
The memset is has to be done as memset(myEntry, 0, sizeof(PHB_ENTRY) * 50);
Rest of your code looks ok.
Probably something wrong in how you are validating it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
sakthii wrote: Problem no #1: I cant see index 0 is intialized to NULL !
memset 's third parameter is a byte count. Your array is 50 elements long, not 50 bytes. Try something like this:
memset(myEntry, 0, sizeof(myEntry));
Steve
|
|
|
|
|
There seems to be two issues here:- The initialization of the myEntry array.
- Assigning values to the members end up at erroneous locations.
#1 has already been addressed by others and should be
memset( myEntry, 0, sizeof( PHB_ENTRY ) * 50 );
memset( myEntry, 0, sizeof( myEntry ) );
The second one seems a little trickier, but for some reason the compiler seems to think that the members of the structure starts four bytes later. Have you possibly removed a four-byte member from the beginning of the structure?
Try and rebuild the complete application as there seems to be a modification done but the object file has not been rebuilt and rebuilding usually fixes these kind of problems.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi sakthii,
In addition to what the other members said you can remove the call to memset completely. You can do this to initialize your array to zero:
PHB_ENTRY myEntry[50] = {0};
Best Wishes,
-David Delaune
|
|
|
|
|
sakthii wrote: Problem no: #3: I see 13 is getting updated in myEntry[1].resevered1 variable...
Even though you are not assigning anything to it?
sakthii wrote: can some one help me out on this strange problem?!
How are you verifying the values?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks to all, memset problem is solved, i could see the structure is set with 0.
sakthii wrote:
Problem no: #3: I see 13 is getting updated in myEntry[1].resevered1 variable...
Even though you are not assigning anything to it?
No. it happens when I am assigning the value to other parameter like myEntry[1].length= 4
How are you verifying the values?
verifying using step by step debugging, I am using Visual Studio 8.
|
|
|
|
|
sakthii wrote: verifying using step by step debugging, I am using Visual Studio 8.
And how do you verify the values ? Are you looking at the variables directly (within the watch window for instance) or are you looking up at the raw memory because you know where your member are located in memory ?
|
|
|
|
|
I am using watch window.
I created new project (windows console application) and added the file to it and same code is working!!!
I think some problem with the Windows Forms Aplication. problem with IDE ?!
|
|
|
|
|
Problem#2 & 3 seems to be occur because of memory-overusage that leads memory corruption at some un-imagined places, I have observed this kind of behavior mostly with mobile technologies. I suggest you to use heap-allocation instead of stack-allocation or try to reduce the array size.
|
|
|
|
|
Do anyone know how to convert a vector to a list in Visual C++?
I tried casting, it does not work for me.
|
|
|
|
|
Are you talking about a std::vector and a std::list ?
Don't think there is a direct conversion, you will need to copy from one to the other.
This signature was proudly tested on animals.
|
|
|
|
|
Yes : std::vector to std::list
What is the best method to copy the data? Can you give an example?
Thanks.
|
|
|
|
|
It's not MFC, but something like:
vector<int> vec;
vector<int>::iterator it;
list<int> l;
for (it = vec.begin(); it != vec.end(); it++)
l.push_back(*it);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I forget to mention it's two different data types see code below:
std::list<rdlresource*> TempRes;
TempRes.clear;
std::vector<rdltemporaryresource*>::iterator it;
for (it = TempResList.begin(); it != TempResList.end(); it++)
TempRes.push_back(*it);
Thanks the help on this.
|
|
|
|
|
Well I guess it did not compile fully earlier, I am still getting the compiler error message below when I tried to copied the data from a vector to a list.
ompiling...
FSSCHED.CPP
c:\program files\ilps\code\fstool\fssched.cpp(1165) : error C2664: 'push_back' : cannot convert parameter 1 from 'class RDLTemporaryResource *' to 'class RDLResource *const & '
Reason: cannot convert from 'class RDLTemporaryResource *' to 'class RDLResource *const '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
fstool.dll - 1 error(s), 0 warning(s)
|
|
|
|
|
That's because your list is for RDLResource* objects while your iterator for that list is for RDLTemporaryResource* objects.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Right. So I am having problems transferring the data from the vector to the list.
How do I work around doing that in my case? I tied casting, it compiled but the application crashes at runtime.
Thanks.
|
|
|
|