Click here to Skip to main content
15,887,861 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionGCC & vga,bitmap.c Pin
tuan111114-Aug-09 17:13
tuan111114-Aug-09 17:13 
AnswerRe: GCC & vga,bitmap.c Pin
Bacon Ultimate Cheeseburger14-Aug-09 17:29
Bacon Ultimate Cheeseburger14-Aug-09 17:29 
AnswerRe: GCC & vga,bitmap.c Pin
Bacon Ultimate Cheeseburger14-Aug-09 20:33
Bacon Ultimate Cheeseburger14-Aug-09 20:33 
QuestionVC7 to VC8 migration Pin
uli200014-Aug-09 9:01
uli200014-Aug-09 9:01 
AnswerRe: VC7 to VC8 migration Pin
«_Superman_»14-Aug-09 17:05
professional«_Superman_»14-Aug-09 17:05 
QuestionTVINSERTSTRUCT - how to get the "item" memeber in CTreeCtrl? Pin
Vaclav_14-Aug-09 8:49
Vaclav_14-Aug-09 8:49 
AnswerRe: TVINSERTSTRUCT - how to get the "item" memeber in CTreeCtrl? Pin
Vaclav_14-Aug-09 8:53
Vaclav_14-Aug-09 8:53 
QuestionLogger! "hijacking" interface! Pin
thelonesquirrely14-Aug-09 7:27
thelonesquirrely14-Aug-09 7:27 
Heya,

So I have to write a logger that emulates log4cxx, without all the awesome features. The main problem I am having is that it needs to be able to be accessed through a Macro with variable args. The Macro has to take variable args of different, unspecified types. I am not sure how this happens. I think I am going to have to rely on the compiler at some point, but I am stumped.

It is easier to show:
the macro:
LOG (Message m, ...)

the Message m comes from an enum (gen'd from xml). It is used like this:
LOG (UNEXPECTED_EVENT, "thread failure");
<< ERROR: UNEXPECTED EVENT: thread failure
LOG (TRACE);
<< TRACE
LOG (DEBUG_MESSAGE, "At line ", line);
<< DEBUG_MESSAGE: At line 7

The types and such are not specified. The format of the message coming out IS though. But it is missing type information.

In the XML the fmt strings are specified like this:
88     <item>
89       <message>CS_CommandHandlingUnknownException</message>
90       <severity>ERROR</severity>
91       <text>An exception was thrown while processing command %1%</text>
92     </item>


I am having problems doing a type-discovery. I am using the va_args structure to get the arguments from the macro:
59   void WriteToLog (Message m, ...)
60   {
61     va_list vlist;
62     char *cur_arg;
63     MessageBody msg_body = msg_map [m];
64
65     va_start (vlist, m);
66
67     for (int i = 0; i < msg_body.fmt_strings.size (); i++)
68     {
69       cur_arg = va_arg (vlist, char *);
70       std::cout << msg_body.fmt_strings[i] << " ";
71       std::cout << "'" <<  cur_arg << "'" << std::endl;
72
73     }
74   }


The msg_body is simply a container for the XML. I parsed out the sections of the string, so that they coincide with the number of args (cause if i didn't know how many args then all hell breaks loose).

Because I have to specify a type in the va_arg I am able to pull off char* fine, but everything else causes segfaults. any ideas on how to get this working? I think it might be time to go back to the drawing board. The one thing I can't change is the macro, nor the XML (le sad Frown | :( . Thanks in advance.
AnswerRe: Logger! "hijacking" interface! Pin
thelonesquirrely14-Aug-09 8:36
thelonesquirrely14-Aug-09 8:36 
QuestionHow to get tool tip text of another application. Pin
onlyjaypatel14-Aug-09 4:27
onlyjaypatel14-Aug-09 4:27 
AnswerRe: How to get tool tip text of another application. Pin
Bacon Ultimate Cheeseburger14-Aug-09 11:26
Bacon Ultimate Cheeseburger14-Aug-09 11:26 
GeneralRe: How to get tool tip text of another application. Pin
onlyjaypatel14-Aug-09 19:29
onlyjaypatel14-Aug-09 19:29 
QuestionSet TitleBAr Pin
kumar sanghvi14-Aug-09 2:52
kumar sanghvi14-Aug-09 2:52 
AnswerRe: Set TitleBAr Pin
kumar sanghvi14-Aug-09 3:45
kumar sanghvi14-Aug-09 3:45 
QuestionRe: Set TitleBAr Pin
David Crow14-Aug-09 5:39
David Crow14-Aug-09 5:39 
GeneralRe: Set TitleBAr Pin
Bacon Ultimate Cheeseburger14-Aug-09 11:52
Bacon Ultimate Cheeseburger14-Aug-09 11:52 
QuestionUniversal font Pin
includeh1014-Aug-09 2:18
includeh1014-Aug-09 2:18 
AnswerRe: Universal font Pin
Stuart Dootson14-Aug-09 2:21
professionalStuart Dootson14-Aug-09 2:21 
AnswerRe: Universal font Pin
Nemanja Trifunovic14-Aug-09 3:00
Nemanja Trifunovic14-Aug-09 3:00 
QuestionNTLM authentication and Wininet.dll dependency Pin
dharani14-Aug-09 0:22
dharani14-Aug-09 0:22 
AnswerRe: NTLM authentication and Wininet.dll dependency Pin
Stuart Dootson14-Aug-09 2:20
professionalStuart Dootson14-Aug-09 2:20 
QuestionDLL Hell ? Pin
Haakon S.14-Aug-09 0:21
Haakon S.14-Aug-09 0:21 
AnswerRe: DLL Hell ? Pin
_AnsHUMAN_ 14-Aug-09 0:29
_AnsHUMAN_ 14-Aug-09 0:29 
GeneralRe: DLL Hell ? Pin
Haakon S.14-Aug-09 4:12
Haakon S.14-Aug-09 4:12 
AnswerRe: DLL Hell ? Pin
Randor 14-Aug-09 2:24
professional Randor 14-Aug-09 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.