2014ǯ08��21��

C/C++�ץ�ץ����å��ε�ư�ΰ㤤��defined�ԡ�

����ε����ǥӥ�ɤ��� Facebook �Ҥ� Warp �ε�ư��Ĵ�٤Ƥ����ꡢ#if �� #elif ������ǤΤ߻��Ѳ�ǽ�� defined ñ��黻�Ҥε�ư�� GCC �Υץ�ץ����å��ȰۤʤꡢGCC �ѤΥإå����������Ǥ��ʤ������ȯ�������Τǡ����λ��Υ��Ǥ���



�ʲ��Τ褦�ʡ����ݤ��Ƹ�����Ǿ��������Ҥ��Ѱդ��ޤ�����
$ cat defined_test.c
#define FOO defined (BAR)
#define BAR

#if FOO
#endif
����� warp.exe �Ǥϥ��顼�ˤʤ�ޤ���FOO �κǽ�Υޥ���Ÿ���λ��� defined �黻�Ҥΰ����� BAR ����� #if defined() �Τ褦��Ÿ���ʺ���ˤ��졢���顼�ˤʤäƤ���褦�˻פ��ޤ���
$ ./warp.exe --stdout defined_test.c
# 1 "defined_test.c"
# 1 "c:\work\warp//"
# 1 "<command-line>"
# 1 "defined_test.c"

defined_test.c(4) : identifier expected after 'defined'
������GCC 4.9.0 �Ǥϡ�-Wall �� -pedantic ���դ��Ƥ�̵�ٹ������̵���̤�ޤ��������ޤǤ�Ĵ�٤Ƥޤ��󤬡������餯 defined �黻�Ҥΰ��������̰������Ƥ���ΤǤϤʤ����Ȼפ��ޤ���
$ gcc -v
...
gcc version 4.9.0 (crosstool-NG hg+unknown-20140610.075849 - 20140615-2.065-a8ad6a6678)
$ gcc -E -Wall -std=c99 -pedantic defined_test.c
# 1 "defined_test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "defined_test.c"
VC++ �Ǥ��̤�褦�Ǥ���
>cl /E defined_test.c
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

defined_test.c
#line 1 "defined_test.c"




#line 6 "defined_test.c"
����� Warp �ΥХ��ʤΤǤ��礦����
������������ȡ������̤����ʤΤǡ��ɤΥץ�ץ����å��ε�ư���������褦�Ǥ���
GCC �� The C Preprocessor �Υޥ˥奢���C/C++/Objective-C ���̡ˤˤϡ��ʲ��Τ褦�˵��Ҥ���Ƥ��ޤ�������-pedantic ���ץ����Ƿٹ𤬽Фʤ��ä����ϵ��ˤʤ�ޤ����ġ���
https://gcc.gnu.org/onlinedocs/cpp/Defined.html
If the defined operator appears as a result of a macro expansion, the C standard says the behavior is undefined. GNU cpp treats it as a genuine defined operator and evaluates it normally. It will warn wherever your code uses this feature if you use the command-line option -pedantic, since other compilers may handle it differently.
�ʰ�����defined �黻�Ҥ��ޥ���Ÿ���η�̤˽и�������硢���� C �Ϥ��ε�ư��̤����Ȥ��Ƥ��롣GNU cpp �Ϥ������ʪ�� defined �黻�ҤȤ��ư������̾��̤�ɾ�����롣¾�Υ���ѥ���ϰۤʤ�谷���򤹤뤫�⤷��ʤ��Τǡ���GNU cpp �ϡ�-pedantic ���ޥ�ɥ饤�󥪥ץ�������Ѥ�����硢���Τ褦�ʻȤ����򤷤Ƥ��륽���������ɤ������ս��ٹ𤹤롣��
C99 �� final draft �� 6.10.1 (p.160) �ˤ⡢�����΢�դ��뵭�Ҥ�����ޤ�����
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf
If the token defined is generated as a result of this replacement process or use of the defined unary operator does not match one of the two specified forms prior to macro replacement, the behavior is undefined.
�ʰ�����defined �ȡ������ִ������η�̤Ȥ����������줿��硢���뤤�ϥޥ����ִ������� defined identifier �� defined ( identifier ) �Τɤ���ˤ�ޥå����ʤ� defined ñ��黻�Ҥλ��Ѥϡ����ε�ư��̤����Ȥʤ롣��
Warp �� Facebook �ҤǼ±��Ѥ���Ƥ���褦�Ǥ�����������ؤ�κ��ۤ�����ˤʤ�ʤ��ΤǤ��礦�������ˤʤ�ޤ���
���ʤߤˡ��䤬��ñ�˻���ϰϤǤϡ�MinGW GCC �� x86_64-gdcproject-mingw32/x86_64-gdcproject-mingw32/sysroot/mingw/include/psdk_inc/intrin-impl.h �Ρ��ʲ��Τ褦�ʥޥ����ʤɤ���windows.h �����������Ƥߤ褦�ȼ¸����Ƥ����������Ȥʤ�ޤ�����
/* The logic for this macro is:
   if the function is not yet defined AND
   (
       (if we are not just defining special OR 
           (we are defining special AND this is one of the ones we are defining)
       )
   )
*/
#define __INTRINSIC_PROLOG(name) (!defined(__INTRINSIC_DEFINED_ ## name)) && ((!defined (__INTRINSIC_ONLYSPECIAL)) || (defined (__INTRINSIC_ONLYSPECIAL) && defined(__INTRINSIC_SPECIAL_ ## name)))


�ȥ�å��Хå�URL

�����Ȥ���

̾��
 
  ³¨Ê¸»ú
 
 
��������
�ǿ�����
���̥���������
�ǿ�������
<%==comments[n].author%>
<% } %>
�������������󥿡�
  • ������
  • ������
  • �߷ס�

<% for ( var i = 0; i < 7; i++ ) { %> <% } %>
<%= wdays[i] %>
<% for ( var i = 0; i < cal.length; i++ ) { %> <% for ( var j = 0; j < cal[i].length; j++) { %> <% } %> <% } %>
0) { %> id="calendar-611743-day-<%= cal[i][j]%>"<% } %>><%= cal[i][j] %>
���ƥ����̥���������
�������饦��
QR������
QR¥³¡¼¥É
���ԥޥ���������ԥ塼��

'); label.html('\ �饤�֥ɥ��֥����ǤϹ���Υѡ����ʥ饤�������¬��Τ��᥯�å���(cookie)����Ѥ��Ƥ��ޤ���
\ ���ΥХʡ����Ĥ��뤫�������³���뤳�Ȥǥ��å����λ��Ѥ�ǧ������������ΤȤ����Ƥ��������ޤ���
\ �ޤ��������ͤ����ҥѡ��ȥʡ���Ȥˤ��������μ�³���ˤ�ꡢ���å����λ��Ѥ�������뤳�Ȥ�Ǥ��ޤ���
\ �ܺ٤��饤�֥ɥ����ѵ���򤴳�ǧ����������\ '); banner.append(label); var closeButton = $('