|
there are at least two ways to get it:
#if defined(ONE)
#if defined(TWO)
...
#endif
#endif
#if defined(ONE) && defined(TWO)
...
#endif
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Many thanks, I was looking for single line #if with 2 defined
Чесноков
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Hi all,
i am using Coledatetime class to find out current time can anyone please tell me that how to get difference between two time values.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
There is the COleDateTimeSpan class for that, see the MSDN example: "Elapsed Time: Automation Classes".
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]
|
|
|
|
|
hii
Here I give my header file and .c file
/* main.h*/
#include <stdio.h>
#include <stdlib.h>
struct linked_list{
int data;
struct linked_list *next;
};
typedef struct linked_list node_t;
void display (void);
node_t *root = 0;
----------------------------------------------------------------------
/* display.c */
#include "./../inc/main.h"
extern node_t *root;
void display ( )
{
node_t *temp = root;
while (temp -> next != root)
printf(" %d", temp->data);
}
----------------------------------------------------------------------------
while compiling it gives this error
qs2/src/display.c:8: multiple definition of `root'
obj/create.o:/qs2/src/create.c:6: first defined here
obj/display.o: In function `display':
I think this error reltes to node_t *root = 0; ,extern node_t *root;
but I dont know how to clear it ...???
seeking help ...!!
Thnaking you
|
|
|
|
|
krish_kumar wrote: node_t *root = 0;
You must NOT initialize the global variable inside the header (.h ) file, change it to:
node_t *root;
Then inside just one source (.c ) file (e.g. create.c ) initialize it this way:
node_t *root = 0;
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]
|
|
|
|
|
If root is already declared inside the main.h file and that header is included in the display.c, then why the extern node_t *root; is declared in display.c? I think you can remove extern node_t *root; from display.c
|
|
|
|
|
That (probably) will not solve his problem, since (apparently) the header file is included both by display.c and create.c (incidentally this shows why you should never define a variable inside a header file).
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]
|
|
|
|
|
Yes, it is better not to declare variable inside the headers.
I was pointing out, when the header is included in the c file, it become a single translation unit. So, the unit already has the variable. Then there is no extern is required.
|
|
|
|
|
Rejeesh.T.S wrote: Yes, it is better not to declare variable inside the headers.
I think you are confusing declaring with defining.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks for correcting. I would have mentioned "defining". 
|
|
|
|
|
You have it backwards.
Your extern node_t *root; belongs in your .h file. It declares to anyone that includes it that there is such a variable that is created someplace and can be used.
Your node_t *root = 0; belongs in exactly one .c file and no .h file. It defines (creates) the variable. You only do this once. If you put this in a header file, than each .c file that uses that header would create a separate variable of that name. Those multiple variables of the same name which are globally visible and accessible would conflict with each other, hence the error multiple definition of `root'
|
|
|
|
|
Hi Guys i have a member function and a variable .. while accessing member function can we have access the variable also....
vikas da
|
|
|
|
|
Can you show with some sample code what you are trying to do. I really didn't get your question.
|
|
|
|
|
tasumisra wrote: Hi Guys i have a member function and a variable .. while accessing member function can we have access the variable also....
If you have also a C++ book, please read it.
On the serious side: read the f#*?in' book!
There are some rules about information hiding in C++ , and what you said doesn't help us answering the question.
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]
|
|
|
|
|
If you couldn't... you wouldn't be able to use Get/Set functions (a.k.a = accessing a function that access the variable)
If that is not the answer you expected, then ask something a bit quite more concrete
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: f that is not the answer you expected, then ask something a bit quite more concrete
May I have a sir (plz plz urgenz)?
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]
|
|
|
|
|
Yes of course you may have it, but not drink it
drinking is not allowed at job
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: drinking is not allowed at job
Nah, they allow me drinking here. They know, when drunk, I'm more productive...
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]
|
|
|
|
|
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I am stuck in the issue. When I run a multi threaded windows service during process I got following error message:
"Microsoft Visual C++ Runtime Library
Runtime Error
This application has requested the Runtime to terminate it in an unusual way. Please contact the applications support team for more information. "
The OS is Microsoft windows xp 2002 sp3. Plz tell me how can i troubleshoot the problem. What could be the cause. How can I find the problematic code?
Thanks for your time.
|
|
|
|
|
bilal haider wrote: Plz tell me how can i troubleshoot the problem.
Use your debugger to track down the problem.
|
|
|
|
|
ofetn a multi-thread versus single thread linking issue
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
I developed my application in VS2008,.Net framework version 3.5 SP1.
Its runs in my machine.But when i run it in another machine its not running.It shows the error
This application has failed to start because the application configuration is incorrect.Reinstalling the application may fix the problem
In that machine VC++6.0 is installed.
How can i avoid this error?
I have to send this applciation to client.I dont know whether they have VS2008
Anu
|
|
|
|