﻿<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://www.yfrobot.com.cn/wiki/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
		<id>https://www.yfrobot.com.cn/wiki/index.php?action=history&amp;feed=atom&amp;title=Const</id>
		<title>Const - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="https://www.yfrobot.com.cn/wiki/index.php?action=history&amp;feed=atom&amp;title=Const"/>
		<link rel="alternate" type="text/html" href="https://www.yfrobot.com.cn/wiki/index.php?title=Const&amp;action=history"/>
		<updated>2026-05-01T21:17:47Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.22.6</generator>

	<entry>
		<id>https://www.yfrobot.com.cn/wiki/index.php?title=Const&amp;diff=1663&amp;oldid=prev</id>
		<title>2017年9月13日 (三) 01:25 Allblue</title>
		<link rel="alternate" type="text/html" href="https://www.yfrobot.com.cn/wiki/index.php?title=Const&amp;diff=1663&amp;oldid=prev"/>
				<updated>2017-09-13T01:25:41Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2017年9月13日 (三) 01:25的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第22行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第22行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;font color=&amp;quot;orange&amp;quot; size=&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;+1&lt;/del&gt;&amp;quot;&amp;gt;'''#define or const'''&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;font color=&amp;quot;orange&amp;quot; size=&amp;quot;&amp;quot;&amp;gt;'''#define or const'''&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:您可以使用'''const'''或'''#define'''创建数字或字符串常量。&amp;#160;对于[[array|array&amp;#160;数组]]，您将需要使用'''const'''。&amp;#160;一般来说，const对于定义常量是优先于#define。&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;:您可以使用'''const'''或'''#define'''创建数字或字符串常量。&amp;#160;对于[[array|array&amp;#160;数组]]，您将需要使用'''const'''。&amp;#160;一般来说，const对于定义常量是优先于#define。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Allblue</name></author>	</entry>

	<entry>
		<id>https://www.yfrobot.com.cn/wiki/index.php?title=Const&amp;diff=1662&amp;oldid=prev</id>
		<title>Allblue：以“=== Const 关键字 ===  const关键字代表常量。 它是一个修改变量行为的变量限定符，使变量“只读”。 这意味着该变量可以像其...”为内容创建页面</title>
		<link rel="alternate" type="text/html" href="https://www.yfrobot.com.cn/wiki/index.php?title=Const&amp;diff=1662&amp;oldid=prev"/>
				<updated>2017-09-13T01:25:10Z</updated>
		
		<summary type="html">&lt;p&gt;以“=== Const 关键字 ===  const关键字代表常量。 它是一个修改变量行为的变量限定符，使变量“只读”。 这意味着该变量可以像其...”为内容创建页面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Const 关键字 ===&lt;br /&gt;
&lt;br /&gt;
const关键字代表常量。 它是一个修改变量行为的变量限定符，使变量“只读”。 这意味着该变量可以像其他类型的其他变量一样使用，但不能更改其值。 如果您尝试将一个值分配给一个常量变量，您将收到编译器错误。&lt;br /&gt;
&lt;br /&gt;
使用const关键字定义的常量遵守管理其他变量的变量范围界定规则。 这和使用#define的陷阱使const关键字成为定义常量的一个很好的方法，并且优于使用[[#define]]。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=&amp;quot;orange&amp;quot; size=&amp;quot;+1&amp;quot;&amp;gt;'''示例'''&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:dimgray&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
const float pi = 3.14;&lt;br /&gt;
float x;&lt;br /&gt;
&lt;br /&gt;
// ....&lt;br /&gt;
&lt;br /&gt;
x = pi * 2;    // it's fine to use consts in math&lt;br /&gt;
&lt;br /&gt;
pi = 7;        // illegal - you can't write to (modify) a constant&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=&amp;quot;orange&amp;quot; size=&amp;quot;+1&amp;quot;&amp;gt;'''#define or const'''&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:您可以使用'''const'''或'''#define'''创建数字或字符串常量。 对于[[array|array 数组]]，您将需要使用'''const'''。 一般来说，const对于定义常量是优先于#define。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=&amp;quot;orange&amp;quot; size=&amp;quot;+1&amp;quot;&amp;gt;'''扩展阅读'''&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:- [[#define]]&lt;br /&gt;
:- [[volatile]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Arduino语法参考 | 返回Arduino语法参考列表]]&lt;br /&gt;
&lt;br /&gt;
更多建议和问题欢迎反馈至 [http://www.yfrobot.com YFRobot论坛]&lt;/div&gt;</summary>
		<author><name>Allblue</name></author>	</entry>

	</feed>