UINT_MAX宏的定义

时间:2018-04-15 13:08:53

标签: c++ macros numeric-limits

我想知道是否有特殊原因将宏UINT_MAX定义为(2147483647 * 2U + 1U),而不是直接在(4294967295U)头文件中定义其真值climits

谢谢大家。

1 个答案:

答案 0 :(得分:4)

就编译代码而言,没有区别,因为编译器会在编译时评估两个常量表达式以产生相同的值。

根据search_item = input("Input The Search Item: ") location = input("Location:") second_location = input("Second_Location:") # city = [ # "Los Angeles", "Chicago", "Houston", "Phoenix", "Philadelphia", "San Antonio", "Fort Worth", # "San Diego", "Dallas", "San Jose", "Austin", "Columbus", "Indianapolis", "Seattle", "St. Paul", "Nashville", # "Louisville", "Plano" # ] # rancity = random.choice(city) class YellowSpider(scrapy.Spider): name = "yellow" start_urls = [ "https://www.yellowpages.com/search?search_terms=" + search_item + "&geo_location_terms=" + location, "https://www.yellowpages.com/search?search_terms=" + search_item + "&geo_location_terms=" + second_location # "https://www.yellowpages.com/search?search_terms=" + search_item + "&geo_location_terms=" + third_location, # "https://www.yellowpages.com/search?search_terms=" + search_item + "&geo_location_terms=" + fourth_location ] def __init__(self): self.seen_business_names = [] self.seen_phonenumbers = [] self.seen_websites = [] self.seen_emails = [] def parse(self, response): for href in response.css('div.v-card a.business-name::attr(href)'): yield response.follow(href, self.businessprofile) for href in response.css('div.pagination a::attr(href)'): yield response.follow(href, self.parse) def businessprofile(self, response): for business in response.css('header#main-header'): item = Item() item['business_name'] = business.css('div.sales-info h1::text').extract() w = business.css('a.secondary-btn.website-link::attr(href)').extract() item['website'] = str(w).strip('[]') if self.start_urls[0]: item['location'] = location if self.start_urls[1]: item['location'] = second_location s = business.css('a.email-business::attr(href)').extract() item['email'] = [item[7:] for item in s] item['phonenumber'] = business.css('p.phone::text').extract_first() for x in item['email']: #new code here, call to self.seen_business_names if x not in self.seen_emails: if item['email']: if item['phonenumber']: if item['website']: self.seen_emails.append(x) yield item 定义UINT_MAX可让您重复使用已定义的常量:

INT_MAX

事实上,这与clang's header does非常相似,为#define UINT_MAX (INT_MAX * 2U + 1U) __INT_MAX__重复使用内部常量INT_MAX

UINT_MAX