|
#define creates a macro, not a function. the macro can look like a function:
#define min(a,b) (a < b ? a : b)
or it can look like a constant:
#define BLOCKSIZE 1024
or it can be just a flag:
#define THIS_FLAG_IS_SET
#ifndef/#ifdef tests to see if a macro with that name has been #defined.
in any case, all of the #**** directives are handled before actual compilation. the preprocessor does something only slightly more complicated than search/replace with #define'd macros, and then hands the result to the compiler.
http://en.wikipedia.org/wiki/C_preprocessor[^]
|
|
|
|
|
howabout this
#define RUNSITSELF
#define TEXT ("TEXT")TEXT
#define DEFINE
#define TEXTSOFTWARE
That there will run defines. if in that order.
thats what im saying. it does run there at text to the processor... like when i use.. "TEXT"+1234;
that runs...
#ifndef is like a if statement if(a==b){ RUNDEFINE; }
thats what i think. the question maybee what can run such a thing.. hmm...
|
|
|
|
|
I don't really understand your question. Could you please rephrase it so it is a bit more understandable ?
Anyway, as Chris already pointed out, a #define is simply a macro. It means that before compilation occurs, all occurrences of the string TEXT in your source file will be replaced by what you specified.
For instance this define:
#define TEXT "Test"
Whenever you have a TEXT somewhere in your code, it will be replaced by "Test". So, it is really something basic, there's nothing which is run or anything like that.
|
|
|
|
|
I have trouble buying that. I know what a library is but all it is bunch of defines and ifndefs and process. you can do the exact same thing in a header except something has to be there to run the header.
What your saying is that they do not run. and that it only replaces. There is more to it than that..
Youve got to realize a small group of people developed the things we have here and are near dead and have fogotten and we have nothing more than a few million developers without header knowlege of function development.
I cant even find information out about headers at all. Yeah how some can use them in general c++ compilers. but what if i wanted to upgrade my compiler to allow that.. is what im saying. Your saying theres no way to make it run regardless of what you type..
but keep in mind this does run...
"STRING"+1234;
runs by the processor and returns int. can be couted as a binary in some cases. that is function. linking those functions to code is difficult that what im trying to find out. like if i typed
#define TEXT "Alphabet"+12345123-"27"
cout << TEXT;
will return that function as int and possibly cout the binary except for the cout function is unable to return the proper information of a running process..
but keep in mind it does run by the processor. all things on here that you can see run by the processor and by the processor use the hardware.. which means that the socalled preprocessor directive should be able to allow functionality within a software. That is my opinion and that is why im here in this forum asking about it. I doubt many know about it to begin with even when it was developed.
modified on Monday, September 14, 2009 3:19 PM
|
|
|
|
|
lgm420 wrote: but keep in mind this does run...
"STRING"+1234;
runs by the processor and returns int.
No this is merely a group of text characters which do nothing on their own, and when this statement is compiled it produces a compiler warning.
I think you still misunderstand the use of #define. The #define statement does not create runnable code, it merely provides a way of using an alias for a source code expression. This alias is then replaced in the source by the preprocessor before the source module is passed to the compiler. Thus in your example:
#define TEXT "Alphabet"+12345123-"27"
cout << TEXT;
the preprocessor converts these statements to
cout << "Alphabet"+12345123-"27";
this is then passed to the compiler, which converts the statement into executable code. Which, incidentally will not produce the result you think it may.
|
|
|
|
|
you can understand the working of the #define commando as text replacement which will done by the precompiler. It replaces the text and done: No thinking about right or wrong: Just do it!!!
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
lgm420 wrote: I believe I understand Defines are functions
No this is not what they are. A #define is merely a way of providing an alias for some characters which can be used anywhere in the source module. The characters may contain source code of any type including statements, constants values etc. The preprocessor will replace these characters in the source code wherever the alias occurs, before the modified source is passed to the compiler.
Example:
#define MESSAGE "Code Project - a great place for information\n"
void main()
{
printf(MESSAGE);
}
output will be: Code Project - a great place for information
For further information see the C/C++ language documentation.
|
|
|
|
|
They have other functionality in there too. not just replacing. there is a couple things in there that it can do beside that in function alone just using the macro as you say... but its available in there to do these things. but what i was trying to say is there has be programability for this thing. There is not way your going to get it to function without some custom programability.
|
|
|
|
|
See my further reply above.
|
|
|
|
|
Hello,
What is best way to communicate shell hook function with my service?
I want to send message that window get activated.
|
|
|
|
|
Create a named event using CreateEvent[^].
Create a thread in your service using CreateThread[^].
In the thread wait for the event to be signaled using WaitForSingleObject[^].
If you want multiple notifications, for example, one for window creation, another for window activation etc., create one event for each and use the WaitForMultipleObjects[^] in your service thread.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I am not sure about the best practice, how ever I guess message sending to the main window would be a bad mechanism, cause in windows vista, you cannot sent message from a process of low Integrity to high Integrity. check here [^]for details
|
|
|
|
|
Maybe, there is another way to do what I want, without using hooks. I use shell hook to detect that user change activated window to other application. It is not good for me that every process must load my hook dll and fire that hook. But at this time I dont have better idea.
Any tips?
|
|
|
|
|
i want to know how to send the input that i was write in rich edit to device??
the idea is simple...when i push the S key...the device also received s...
|
|
|
|
|
I recommend giving more details about your project, what kind of device, how is it connected to the computer, what protocol is it suposed to be using, otherwise don't expect any usefull answers. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
From your description it would seem that you need to capture key presses, so your program would need to respond to the WM_KEY type messages and then send each character to your device. However you do not specify what type of device you are interested in so it is impossible to know how to send it the character.
I do not understand what this has to do with rich edit!
|
|
|
|
|
<br />
IXMLDOMDocument *pDoc = NULL;<br />
BSTR bstr = NULL;<br />
...<br />
bstr = filename.AllocSysString();<br />
hr = pDoc->load (bstr, b_load);<br />
filename is a CString type,how can i slove this problem?
i 've tried ,then i have no regret
|
|
|
|
|
The load 's prototype is below, this is the reason.
virtual HRESULT STDMETHODCALLTYPE load(
VARIANT xmlSource,
VARIANT_BOOL *isSuccessful) = 0;
One solution is this.
#include <comdef.h>
...
bstr = filename.AllocSysString();
_variant_t file(bstr);
hr = pDoc->load (file, b_load);
|
|
|
|
|
Or you can use the ATL class CComVariant in a similar way.
CComVariant file(filename);
CComVariant success(false);
hr = pDoc->load(file, &success);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi,
I have two applications suppose AppA AppB. Application AppA is window class application and AppB is non windowbased application. AppA, I have a message loop which used to get all regular messages. But I want to know how from AppB I will know which message AppA got.?
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
To clarify, you want AppB to monitor AppA's messages?
"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
|
|
|
|
|
Yes, exactly.
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
|
You know that you could also use Spy++[^]. Shows you window messages and even more.
|
|
|
|
|
Why do you need to do such a thing? What exactly are you writing? Can't you just have App A to send only relevant messages to App B instead?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|