当前位置: 首页>>代码示例>>C++>>正文


C++ cpp_define函数代码示例

本文整理汇总了C++中cpp_define函数的典型用法代码示例。如果您正苦于以下问题:C++ cpp_define函数的具体用法?C++ cpp_define怎么用?C++ cpp_define使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cpp_define函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ix86_target_macros

void
ix86_target_macros (void)
{
  /* 32/64-bit won't change with target specific options, so do the assert and
     builtin_define_std calls here.  */
  if (TARGET_64BIT)
    {
      cpp_assert (parse_in, "cpu=x86_64");
      cpp_assert (parse_in, "machine=x86_64");
      cpp_define (parse_in, "__amd64");
      cpp_define (parse_in, "__amd64__");
      cpp_define (parse_in, "__x86_64");
      cpp_define (parse_in, "__x86_64__");
    }
  else
    {
      cpp_assert (parse_in, "cpu=i386");
      cpp_assert (parse_in, "machine=i386");
      builtin_define_std ("i386");
    }

  ix86_target_macros_internal (ix86_isa_flags,
			       ix86_arch,
			       ix86_tune,
			       ix86_fpmath,
			       cpp_define);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:27,代码来源:i386-c.c

示例2: define_builtin_macros_for_compilation_flags

/* Define various built-in CPP macros that depend on language-independent
   compilation flags.  */
static void
define_builtin_macros_for_compilation_flags (cpp_reader *pfile)
{
  if (flag_pic)
    {
      cpp_define_formatted (pfile, "__pic__=%d", flag_pic);
      cpp_define_formatted (pfile, "__PIC__=%d", flag_pic);
    }
  if (flag_pie)
    {
      cpp_define_formatted (pfile, "__pie__=%d", flag_pie);
      cpp_define_formatted (pfile, "__PIE__=%d", flag_pie);
    }

  if (optimize_size)
    cpp_define (pfile, "__OPTIMIZE_SIZE__");
  if (optimize)
    cpp_define (pfile, "__OPTIMIZE__");

  if (fast_math_flags_set_p (&global_options))
    cpp_define (pfile, "__FAST_MATH__");
  if (flag_signaling_nans)
    cpp_define (pfile, "__SUPPORT_SNAN__");

  cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d",
			flag_finite_math_only);
}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:29,代码来源:cppbuiltin.c

示例3: spu_cpu_cpp_builtins

void
spu_cpu_cpp_builtins (struct cpp_reader *pfile)
{
  builtin_define_std ("__SPU__");
  cpp_assert (pfile, "cpu=spu");
  cpp_assert (pfile, "machine=spu");
  if (spu_arch == PROCESSOR_CELLEDP)
    builtin_define_std ("__SPU_EDP__");
  builtin_define_std ("__vector=__attribute__((__spu_vector__))");

  if (!flag_iso)
    {
      /* Define this when supporting context-sensitive keywords.  */
      cpp_define (pfile, "__VECTOR_KEYWORD_SUPPORTED__");
      cpp_define (pfile, "vector=vector");

      /* Initialize vector keywords.  */
      __vector_keyword = get_identifier ("__vector");
      C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL;
      vector_keyword = get_identifier ("vector");
      C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL;

      /* Enable context-sensitive macros.  */
      cpp_get_callbacks (pfile)->macro_to_expand = spu_macro_to_expand;
    }
}
开发者ID:PennPanda,项目名称:MIT--6.828,代码行数:26,代码来源:spu-c.c

示例4: define_builtin_macros_for_lp64

/* Define built-in macros for LP64 targets. */
static void
define_builtin_macros_for_lp64 (cpp_reader *pfile)
{
  if (TYPE_PRECISION (long_integer_type_node) == 64
      && POINTER_SIZE == 64
      && TYPE_PRECISION (integer_type_node) == 32)
    {
      cpp_define (pfile, "_LP64");
      cpp_define (pfile, "__LP64__");
    }
}
开发者ID:AHelper,项目名称:gcc,代码行数:12,代码来源:cppbuiltin.c

示例5: define_builtin_macros_for_type_sizes

/* Define macros for size of basic C types.  */
static void
define_builtin_macros_for_type_sizes (cpp_reader *pfile)
{
#define define_type_sizeof(NAME, TYPE)                             \
    cpp_define_formatted (pfile, NAME"="HOST_WIDE_INT_PRINT_DEC,   \
                          tree_to_uhwi (TYPE_SIZE_UNIT (TYPE)))

  define_type_sizeof ("__SIZEOF_INT__", integer_type_node);
  define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node);
  define_type_sizeof ("__SIZEOF_LONG_LONG__", long_long_integer_type_node);
  define_type_sizeof ("__SIZEOF_SHORT__", short_integer_type_node);
  define_type_sizeof ("__SIZEOF_FLOAT__", float_type_node);
  define_type_sizeof ("__SIZEOF_DOUBLE__", double_type_node);
  define_type_sizeof ("__SIZEOF_LONG_DOUBLE__", long_double_type_node);
  define_type_sizeof ("__SIZEOF_SIZE_T__", size_type_node);

#undef define_type_sizeof

  cpp_define_formatted (pfile, "__CHAR_BIT__=%u",
			TYPE_PRECISION (char_type_node));
  cpp_define_formatted (pfile, "__BIGGEST_ALIGNMENT__=%d",
			BIGGEST_ALIGNMENT / BITS_PER_UNIT);

  /* Define constants useful for implementing endian.h.  */
  cpp_define (pfile, "__ORDER_LITTLE_ENDIAN__=1234");
  cpp_define (pfile, "__ORDER_BIG_ENDIAN__=4321");
  cpp_define (pfile, "__ORDER_PDP_ENDIAN__=3412");

  if (WORDS_BIG_ENDIAN == BYTES_BIG_ENDIAN)
    cpp_define_formatted (pfile, "__BYTE_ORDER__=%s",
			  (WORDS_BIG_ENDIAN
			   ? "__ORDER_BIG_ENDIAN__"
			   : "__ORDER_LITTLE_ENDIAN__"));
  else
    {
      /* Assert that we're only dealing with the PDP11 case.  */
      gcc_assert (!BYTES_BIG_ENDIAN);
      gcc_assert (WORDS_BIG_ENDIAN);

      cpp_define (pfile, "__BYTE_ORDER__=__ORDER_PDP_ENDIAN__");
    }

  cpp_define_formatted (pfile, "__FLOAT_WORD_ORDER__=%s",
                        (targetm.float_words_big_endian ()
                         ? "__ORDER_BIG_ENDIAN__"
                         : "__ORDER_LITTLE_ENDIAN__"));

  /* ptr_type_node can't be used here since ptr_mode is only set when
     toplev calls backend_init which is not done with -E switch.  */
  cpp_define_formatted (pfile, "__SIZEOF_POINTER__=%d",
			1 << ceil_log2 ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT));
}
开发者ID:AHelper,项目名称:gcc,代码行数:53,代码来源:cppbuiltin.c

示例6: gcc_python_define_macro

static PyObject*
gcc_python_define_macro(PyObject *self,
                        PyObject *args, PyObject *kwargs)
{
    const char *macro;
    char *keywords[] = {"macro",
                        NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     "s:define_preprocessor_name", keywords,
                                     &macro)) {
        return NULL;
    }

    if (0) {
        fprintf(stderr, "gcc.define_macro(\"%s\")\n", macro);
    }

    if (!parse_in) {
        return PyErr_Format(PyExc_ValueError,
                            "gcc.define_macro(\"%s\") called without a compilation unit",
                            macro);
    }

    if (!gcc_python_is_within_event(NULL)) {
        return PyErr_Format(PyExc_ValueError,
                            "gcc.define_macro(\"%s\") called from outside an event callback",
                            macro);
    }

    cpp_define (parse_in, macro);

    Py_RETURN_NONE;
}
开发者ID:eevee,项目名称:gcc-python-plugin,代码行数:34,代码来源:gcc-python.c

示例7: def_or_undef_macro

static void
def_or_undef_macro(struct cpp_reader* pfile, const char *name, bool def_p)
{
  if (def_p)
    cpp_define (pfile, name);
  else
    cpp_undef (pfile, name);
}
开发者ID:ollie314,项目名称:gcc,代码行数:8,代码来源:arm-c.c

示例8: s390_cpu_cpp_builtins

/* Define platform dependent macros.  */
void
s390_cpu_cpp_builtins (cpp_reader *pfile)
{
  struct cl_target_option opts;

  cpp_assert (pfile, "cpu=s390");
  cpp_assert (pfile, "machine=s390");
  cpp_define (pfile, "__s390__");
  if (TARGET_ZARCH)
    cpp_define (pfile, "__zarch__");
  if (TARGET_64BIT)
    cpp_define (pfile, "__s390x__");
  if (TARGET_LONG_DOUBLE_128)
    cpp_define (pfile, "__LONG_DOUBLE_128__");
  cl_target_option_save (&opts, &global_options);
  s390_cpu_cpp_builtins_internal (pfile, &opts, NULL);
}
开发者ID:WojciechMigda,项目名称:gcc,代码行数:18,代码来源:s390-c.c

示例9: aarch64_def_or_undef

static void
aarch64_def_or_undef (bool def_p, const char *macro, cpp_reader *pfile)
{
  if (def_p)
    cpp_define (pfile, macro);
  else
    cpp_undef (pfile, macro);
}
开发者ID:nguyentu1602,项目名称:gcc,代码行数:8,代码来源:aarch64-c.c

示例10: cci_attribute

static void cci_attribute(void *pfile_v,const char *keyword, const char *target,
                   int varargs, int n) {
  struct cpp_reader *pfile = (struct cpp_reader *)pfile_v;
  int params_specified = 0;
  char *buffer,*c;
  int size;
  int i;

  if (n) {
    for (c = target; *c; c++) {
      if ((*c == 'P') && (c[1] >= '0') && (c[1] <= '9')) {
        params_specified=1;
        break;
      }
    }
  }
  size = strlen(keyword)+sizeof("__attribute__(())")+strlen(target)+1;
  if (n) {
    if (params_specified == 0) {
      size += 8 * n;  /* up to 99 params: Pnn, */
    }
  }
  if (varargs) size += strlen("=()(),...__VA_ARGS__");
  buffer = (char *)xmalloc(size);
  c = buffer;
  c += sprintf(c,"%s",keyword);
  if (n || varargs) {
    *c++ = '(';
    for (i = 1; i <= n; i++) {
      c += sprintf(c, "P%d", i);
      if (i < n) *c += ',';
    }
    if (varargs) {
      if (n) *c++=',';
      c += sprintf(c, "...");
    }
    *c++ = ')';
  }
  c += sprintf(c, "=__attribute__((%s", target);
  if ((n || varargs) && !params_specified) {
    *c++ = '(';
    for (i = 1; i <= n; i++) {
      c += sprintf(c, "P%d", i);
      if (i < n) *c += ',';
    }
    if (varargs) {
      if (n) *c++=',';
      c += sprintf(c, "__VA_ARGS__");
    }
    *c++ = ')';
  }
  *c++ = ')';
  *c++ = ')';
  *c++ = 0;

  cpp_define(pfile, buffer);
  free(buffer);
}
开发者ID:fabio-d,项目名称:xc16plusplus-source,代码行数:58,代码来源:cci.c

示例11: s390_cpu_cpp_builtins_internal

/* Internal function to either define or undef the appropriate system
   macros.  */
static void
s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
				struct cl_target_option *opts,
				const struct cl_target_option *old_opts)
{
  s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts,
			   "__HTM__", "__HTM__");
  s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts,
			   "__VX__", "__VX__");
  s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
			   "__VEC__=10302", "__VEC__");
  s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
			   "__vector=__attribute__((vector_size(16)))",
			   "__vector__");
  s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
			   "__bool=__attribute__((s390_vector_bool)) unsigned",
			   "__bool");
  {
    char macro_def[64];
    gcc_assert (s390_arch != PROCESSOR_NATIVE);
    sprintf (macro_def, "__ARCH__=%d", processor_table[s390_arch].arch_level);
    cpp_undef (pfile, "__ARCH__");
    cpp_define (pfile, macro_def);
  }

  if (!flag_iso)
    {
      s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
			       "__VECTOR_KEYWORD_SUPPORTED__",
			       "__VECTOR_KEYWORD_SUPPORTED__");
      s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
			       "vector=vector", "vector");
      s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
			       "bool=bool", "bool");
      if (TARGET_ZVECTOR_P (opts->x_target_flags) && __vector_keyword == NULL)
	{
	  __vector_keyword = get_identifier ("__vector");
	  C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL;

	  vector_keyword = get_identifier ("vector");
	  C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL;

	  __bool_keyword = get_identifier ("__bool");
	  C_CPP_HASHNODE (__bool_keyword)->flags |= NODE_CONDITIONAL;

	  bool_keyword = get_identifier ("bool");
	  C_CPP_HASHNODE (bool_keyword)->flags |= NODE_CONDITIONAL;

	  _Bool_keyword = get_identifier ("_Bool");
	  C_CPP_HASHNODE (_Bool_keyword)->flags |= NODE_CONDITIONAL;

	  /* Enable context-sensitive macros.  */
	  cpp_get_callbacks (pfile)->macro_to_expand = s390_macro_to_expand;
	}
    }
}
开发者ID:Lucretia,项目名称:gcc,代码行数:58,代码来源:s390-c.c

示例12: ix86_target_macros

void
ix86_target_macros (void)
{
  /* 32/64-bit won't change with target specific options, so do the assert and
     builtin_define_std calls here.  */
  if (TARGET_64BIT)
    {
      cpp_assert (parse_in, "cpu=x86_64");
      cpp_assert (parse_in, "machine=x86_64");
      cpp_define (parse_in, "__amd64");
      cpp_define (parse_in, "__amd64__");
      cpp_define (parse_in, "__x86_64");
      cpp_define (parse_in, "__x86_64__");
      if (TARGET_X32)
	{
	  cpp_define (parse_in, "_ILP32");
	  cpp_define (parse_in, "__ILP32__");
	}
    }
  else
    {
      cpp_assert (parse_in, "cpu=i386");
      cpp_assert (parse_in, "machine=i386");
      builtin_define_std ("i386");
    }

  cpp_define_formatted (parse_in, "__ATOMIC_HLE_ACQUIRE=%d", IX86_HLE_ACQUIRE);
  cpp_define_formatted (parse_in, "__ATOMIC_HLE_RELEASE=%d", IX86_HLE_RELEASE);

  ix86_target_macros_internal (ix86_isa_flags,
			       ix86_arch,
			       ix86_tune,
			       ix86_fpmath,
			       cpp_define);
}
开发者ID:keparo,项目名称:gcc,代码行数:35,代码来源:i386-c.c

示例13: sparc_target_macros

void
sparc_target_macros (void)
{
  builtin_define_std ("sparc");

  if (TARGET_64BIT)
    {
      cpp_assert (parse_in, "cpu=sparc64");
      cpp_assert (parse_in, "machine=sparc64");
    }
  else
    {
      cpp_assert (parse_in, "cpu=sparc");
      cpp_assert (parse_in, "machine=sparc");
    }

  if (TARGET_VIS3)
    {
      cpp_define (parse_in, "__VIS__=0x300");
      cpp_define (parse_in, "__VIS=0x300");
    }
  else if (TARGET_VIS2)
    {
      cpp_define (parse_in, "__VIS__=0x200");
      cpp_define (parse_in, "__VIS=0x200");
    }
  else if (TARGET_VIS)
    {
      cpp_define (parse_in, "__VIS__=0x100");
      cpp_define (parse_in, "__VIS=0x100");
    }
}
开发者ID:earonesty,项目名称:gcc,代码行数:32,代码来源:sparc-c.c

示例14: main

int main(int argc, char *argv[])
{
    int ofd = 1;
    int i = 1;
    char *s1, *s2;
    int len = 0;
    char *cbuf;
    int clen;
    while (i < argc && argv[i][0] == '-') {
        if (argv[i][1] == 'I')
            cpp_addpath(argv[i][2] ? argv[i] + 2 : argv[++i]);
        if (argv[i][1] == 'D') {
            char *name = argv[i] + 2;
            char *def = "";
            char *eq = strchr(name, '=');
            if (eq) {
                *eq = '\0';
                def = eq + 1;
            }
            cpp_define(name, def);
        }
        i++;
    }
    if (i + 1 >= argc) {
        printf("usage: npp [-I idir] [-D define] input output\n");
        return 0;
    }
    if (cpp_init(argv[i++]))
        die("npp: cannot open <%s>\n", argv[i - 1]);
    ofd = open(argv[i++], O_WRONLY | O_TRUNC | O_CREAT, 0600);
    if (ofd < 0)
        die("npp: cannot open <%s>\n", argv[i - 1]);
    s1 = malloc(OBUFSZ);
    s2 = malloc(OBUFSZ);
    if (!s1 || !s2)
        die("npp: cannot allocate enough memory\n");
    while (!cpp_read(&cbuf, &clen)) {
        memcpy(s1 + len, cbuf, clen);
        len += clen;
    }
    len = rmcomments(s2, s1, len);
    xwrite(ofd, s2, len);
    close(ofd);
    return 0;
}
开发者ID:gaoxiaojun,项目名称:neatcc,代码行数:45,代码来源:npp.c

示例15: cci_define

static void cci_define(void *pfile_v, const char *keyword, const char *target) {
  struct cpp_reader *pfile = (struct cpp_reader *)pfile_v;
  char *buffer;

  if (target)
    {
      buffer = (char *)xmalloc(strlen(keyword) + strlen(target) + 6);
      sprintf(buffer,"%s=%s", keyword, target);
    }
  else
    {
      buffer = (char *)xmalloc(strlen(keyword) + strlen("=") + 6);
      sprintf(buffer,"%s=", keyword);
    }
  cpp_define(pfile, buffer);
  free(buffer);
  return;
}
开发者ID:fabio-d,项目名称:xc16plusplus-source,代码行数:18,代码来源:cci.c


注:本文中的cpp_define函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。