预处理在#define之间找到最大值

时间:2015-12-09 09:03:27

标签: macros max c-preprocessor x-macros

我有两个头文件使用不同的值进行相同的定义:

 file1.h:
          #define NUM_OF_TREES 10
 file2.h:
          #define NUM_OF_TREES 20

在我要定义的另一个文件中      limits.h中               #define MAX_NUM_OF_TREES 如何使用宏指定静态时间(预处理)的最大值?

1 个答案:

答案 0 :(得分:0)

file1.h:

<?php

function place_ID($location)
{
$locationclean = str_replace (" ", "+", $location);
$data = "https://maps.googleapis.com/maps/api/place/textsearch/xml?query=" . $locationclean . "&key=YOUR_KEY";

$xml = file_get_contents($data);
$xml = simplexml_load_string($xml);

foreach($xml->result->type as $key => $value){
    $location_id = $value;
    echo $location_id;
    echo "<br>";
}
}
place_ID("kfc");

?>

file2.h:

  #define NUM_OF_TREES 10
  typedef unsigned char NUM1[NUM_OF_TREES];

file3.c中:

  #define NUM_OF_TREES 20
  typedef unsigned char NUM2[NUM_OF_TREES];