Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #149837 > unrolled thread

what does # mean?

Started byT <T@invalid.invalid>
First post2020-02-07 17:26 -0800
Last post2020-02-08 13:38 -0800
Articles 8 — 5 participants

Back to article view | Back to comp.lang.c


Contents

  what does # mean? T <T@invalid.invalid> - 2020-02-07 17:26 -0800
    Re: what does # mean? luser droog <luser.droog@gmail.com> - 2020-02-07 17:51 -0800
      Re: what does # mean? T <T@invalid.invalid> - 2020-02-07 18:00 -0800
    Re: what does # mean? T <T@invalid.invalid> - 2020-02-07 18:00 -0800
    Re: what does # mean? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-02-07 20:04 -0800
      Re: what does # mean? T <T@invalid.invalid> - 2020-02-08 00:10 -0800
      Re: what does # mean? scott@slp53.sl.home (Scott Lurndal) - 2020-02-08 18:35 +0000
        Re: what does # mean? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-08 13:38 -0800

#149837 — what does # mean?

FromT <T@invalid.invalid>
Date2020-02-07 17:26 -0800
Subjectwhat does # mean?
Message-ID<r1l2nb$n2s$1@dont-email.me>
Hi All

what does the "#" in

      #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)

mean?

And is "define" what others call a constant?

Many thanks,
-T

[toc] | [next] | [standalone]


#149840

Fromluser droog <luser.droog@gmail.com>
Date2020-02-07 17:51 -0800
Message-ID<c12b6811-5133-4c71-931f-d658e8285054@googlegroups.com>
In reply to#149837
On Friday, February 7, 2020 at 7:26:13 PM UTC-6, T wrote:
> Hi All
> 
> what does the "#" in
> 
>       #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)
> 
> mean?
> 
> And is "define" what others call a constant?
> 
> Many thanks,
> -T

The hash # introduces a preprocessor directive. #define creates
a proprocessor macro, in this case an object-like macro. It's 
similar to a constant, but it's purely based on textual substitution.

[toc] | [prev] | [next] | [standalone]


#149841

FromT <T@invalid.invalid>
Date2020-02-07 18:00 -0800
Message-ID<r1l4n8$qou$1@dont-email.me>
In reply to#149840
On 2020-02-07 17:51, luser droog wrote:
> On Friday, February 7, 2020 at 7:26:13 PM UTC-6, T wrote:
>> Hi All
>>
>> what does the "#" in
>>
>>        #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)
>>
>> mean?
>>
>> And is "define" what others call a constant?
>>
>> Many thanks,
>> -T
> 
> The hash # introduces a preprocessor directive. #define creates
> a proprocessor macro, in this case an object-like macro. It's
> similar to a constant, but it's purely based on textual substitution.
> 

Interesting.  Thank you!

[toc] | [prev] | [next] | [standalone]


#149842

FromT <T@invalid.invalid>
Date2020-02-07 18:00 -0800
Message-ID<r1l4nk$qou$2@dont-email.me>
In reply to#149837
On 2020-02-07 17:36, Stefan Ram wrote:
> T <T@invalid.invalid> writes:
>> what does the "#" in
>>       #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)
>> mean?
> 
>    It means that this line is a preprocessing directive.
> 
>    A preprocessing directive of the form
> 
> # define identifier replacement-list new-line
> 
>    causes each subsequent instance of the identifier to be
>    replaced by the remainder of the directive.
> 
> 

Thank you!

[toc] | [prev] | [next] | [standalone]


#149844

FromJames Kuyper <jameskuyper@alumni.caltech.edu>
Date2020-02-07 20:04 -0800
Message-ID<6dcd71aa-6b41-4193-8d53-813dbc198686@googlegroups.com>
In reply to#149837
On Friday, February 7, 2020 at 8:26:13 PM UTC-5, T wrote:
> Hi All
> 
> what does the "#" in
> 
>       #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)
> 
> mean?
> 
> And is "define" what others call a constant?

The # does not mean anything on it's own, but every preprocessing
directive starts with #. #define is one kind of preprocessing directive.
It defines a macro, in this case GDK_SELECTION_SECONDARY. Associated
with a macro is its replacement text, in this case  "GDK_MAKE_ATOM (2)".
After a macro is defined, subsequent occurrences of the macro get
replaced with the replacement text for that macro. Therefore, if you had
a line like

  int n = GDK_SELECTION_SECONDARY;

Then after replacement, it would say:

  int n = GDK_MAKE_ATOM (2);

There are some moderately complicated rules governing special cases with
macros, but at your level the only important thing you need to know is
that the macro gets replaced by its replacement text. The expansion of a
macro can be a constant, but this is not an example. The following is an
example:

  #define MONTHS_PER_YEAR 12

[toc] | [prev] | [next] | [standalone]


#149846

FromT <T@invalid.invalid>
Date2020-02-08 00:10 -0800
Message-ID<r1lqec$71e$1@dont-email.me>
In reply to#149844
On 2020-02-07 20:04, James Kuyper wrote:
> On Friday, February 7, 2020 at 8:26:13 PM UTC-5, T wrote:
>> Hi All
>>
>> what does the "#" in
>>
>>        #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)
>>
>> mean?
>>
>> And is "define" what others call a constant?
> 
> The # does not mean anything on it's own, but every preprocessing
> directive starts with #. #define is one kind of preprocessing directive.
> It defines a macro, in this case GDK_SELECTION_SECONDARY. Associated
> with a macro is its replacement text, in this case  "GDK_MAKE_ATOM (2)".
> After a macro is defined, subsequent occurrences of the macro get
> replaced with the replacement text for that macro. Therefore, if you had
> a line like
> 
>    int n = GDK_SELECTION_SECONDARY;
> 
> Then after replacement, it would say:
> 
>    int n = GDK_MAKE_ATOM (2);
> 
> There are some moderately complicated rules governing special cases with
> macros, but at your level the only important thing you need to know is
> that the macro gets replaced by its replacement text. The expansion of a
> macro can be a constant, but this is not an example. The following is an
> example:
> 
>    #define MONTHS_PER_YEAR 12
> 


Thank you!

[toc] | [prev] | [next] | [standalone]


#149860

Fromscott@slp53.sl.home (Scott Lurndal)
Date2020-02-08 18:35 +0000
Message-ID<jcD%F.118259$_R3.107762@fx36.iad>
In reply to#149844
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>On Friday, February 7, 2020 at 8:26:13 PM UTC-5, T wrote:
>> Hi All
>> 
>> what does the "#" in
>> 
>>       #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)
>> 
>> mean?
>> 
>> And is "define" what others call a constant?
>
>The # does not mean anything on it's own, 

Although to be strictly pedantic, in the days of early
C compilers, the C pre-processor would only be run if
the first byte of the source file was '#'.    One often
saw source files where the first line was a naked octothorpe.

[toc] | [prev] | [next] | [standalone]


#149866

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2020-02-08 13:38 -0800
Message-ID<87eev4220a.fsf@nosuchdomain.example.com>
In reply to#149860
scott@slp53.sl.home (Scott Lurndal) writes:
> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>>On Friday, February 7, 2020 at 8:26:13 PM UTC-5, T wrote:
>>> Hi All
>>> 
>>> what does the "#" in
>>> 
>>>       #define GDK_SELECTION_SECONDARY  GDK_MAKE_ATOM (2)
>>> 
>>> mean?
>>> 
>>> And is "define" what others call a constant?
>>
>>The # does not mean anything on it's own, 
>
> Although to be strictly pedantic, in the days of early
> C compilers, the C pre-processor would only be run if
> the first byte of the source file was '#'.    One often
> saw source files where the first line was a naked octothorpe.

And a # on a line by itself is a "null directive".  It has no effect.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web