“无用类型限定符”错误(“useless type qualifier” error)
以下代码出现以下错误。 我试图找出问题出在谷歌的哪个位置,但我没有找到有用的东西。
Compiling /home/tectu/projects/resources/chibios/ext/lcd/touchpad.c In file included from /home/tectu/projects/resources/chibios/ext/lcd/touchpad.c:1:0: /home/tectu/projects/resources/chibios/ext/lcd/touchpad.h:17:1: warning: useless type qualifier in empty declaration [enabled by default]
以下是
touchpad.h
第12行到第17行的代码:volatile struct cal { float xm; float ym; float xn; float yn; };
下面是我在
touchpad.c
使用这个结构的方法:static struct cal cal = { 1, 1, 0, 0 };
任何人都可以看到灯光? :d
I get the following error with the following code. I tried to figure out where the problem is over Google, but I didn't find anything helpful.
Compiling /home/tectu/projects/resources/chibios/ext/lcd/touchpad.c In file included from /home/tectu/projects/resources/chibios/ext/lcd/touchpad.c:1:0: /home/tectu/projects/resources/chibios/ext/lcd/touchpad.h:17:1: warning: useless type qualifier in empty declaration [enabled by default]
Here's the the code from line 12 to line 17 from
touchpad.h
:volatile struct cal { float xm; float ym; float xn; float yn; };
And here's how I use this struct inside
touchpad.c
:static struct cal cal = { 1, 1, 0, 0 };
Can anyone show me the light? :D
原文:https://stackoverflow.com/questions/10978370
最满意答案
如果您使用散列而不是数组来组织EmergInfo数据,您将能够一次搜索并替换所有字段。
my %EmergInfo = ( Location => 'New York', LastUpdate => 'Feb 17, 2015', OPHONE1 => '800-555-1212', etc => '...', ); my $joined_keys = join('|', keys %EmergInfo); my $regexp = qr/#($joined_keys)/; while (<DATA>) { s/$regexp/$EmergInfo{$1}/g; print; } __DATA__ #Location #LastUpdate #AddInfo #SpecInst #OPHONE1
编辑:请注意,我在while循环外创建一次编译的正则表达式,以便它不必为循环内的每个迭代创建。
If you organize your EmergInfo data in a hash instead of an array, you will be able to search and replace all fields at once.
my %EmergInfo = ( Location => 'New York', LastUpdate => 'Feb 17, 2015', OPHONE1 => '800-555-1212', etc => '...', ); my $joined_keys = join('|', keys %EmergInfo); my $regexp = qr/#($joined_keys)/; while (<DATA>) { s/$regexp/$EmergInfo{$1}/g; print; } __DATA__ #Location #LastUpdate #AddInfo #SpecInst #OPHONE1
EDIT: note that I'm creating the compiled regular expression once outside the while loop so that it doesn't have to be created for each iteration within the loop.
相关问答
更多-
结合多个正则表达式(Combining multiple Regex)[2022-11-26]
如果您只是想过滤掉负数列表中以单词开头的字符串,请在模式开头处使用负向前视图,并使用替代方式来覆盖该单词列表: ^(?!database|audit|index|analysis|extract|good|bad).*$ 如果你想检查正匹配,或想要更复杂的模式,那么你可以用适当的逻辑来替换.* 。 演示 If you just want to filter out strings which start with words in your negative list, then use a negati ... -
python的重新:多个正则表达式(python's re: multiple regex)[2022-03-04]
>>> p = u'((?:(?! ).)*cheese.*?)' >>> patt = re.compile(p, re.UNICODE | re.DOTALL | re.IGNORECASE) >>> patt.findall(cheesetext) [u'I love cheese.', u'Yeah, cheese is all I need.', u'Cheese is REALLY I need.', u'Everyone can like cheese.'] ... -
NodeJS REGEX:高效正则表达式搜索多个关键字?(NodeJS REGEX: Efficient Regex Search for multiple keywords?)[2023-06-06]
我会使用一个简单的函数而不是正则表达式,因为在这种情况下,需要一个复杂的正则表达式。 /** * * Look for all `items' inside `str'. * *@param str the string to search inside *@param items all items that must appear in the string * *@return * TRUE => All items were found * FALSE => A ... -
这很简单。 让我们一步一步地制作这个正则表达式: 首先,让我们使用锚来定义字符串的开头和结尾: ^$ I want: no "space" ,我们有\S匹配非白色空格字符: ^\S+$ no "../" ,让我们添加一个否定的前瞻^(?!.*[.][.]/)\S+$ ,请注意我们不需要在字符类中转义点。 至于前锋,我们将使用不同的分隔符 one optional "/" ,我们可以添加一个负向前瞻,防止2个前锋^(?!(?:.*/){2})(?!.*[.][.]/)\S+$ 让我们定义分隔符并添加s修饰符以 ...
-
根据我的理解 您可以使用替换| 结合不同的正则表达式 \b ((?
[[:upper:]]+)| (? [A-Z][a-z]+[A-Z]*+)| (? [A-z]*[A-Z][A-z]*+)| (? [A-Z][\w-]*(\s+[A-Z][\w-]*)+)) \b 正则表达式示例 Based on what I understood You can use alternations | to combine t ... -
如何迭代多个正则表达式的?(How to iterate multiple regex's?)[2022-06-19]
如果您使用散列而不是数组来组织EmergInfo数据,您将能够一次搜索并替换所有字段。 my %EmergInfo = ( Location => 'New York', LastUpdate => 'Feb 17, 2015', OPHONE1 => '800-555-1212', etc => '...', ); my $joined_keys = join('|', keys %EmergInfo); my $regexp = qr/#($joined_keys)/; while ... -
您正在尝试在正则表达式中使用备用列表 ,而是使用字符类 ( "[\\baddAction\\b|\\bintentFilter\\b] )。对于字符类,其中的所有字符都单独匹配,而不是给定的序列。 您学习了单词边界 ,还需要了解分组的工作原理。 你有一个结构: 双字引号和括号中的 单词字符 + 单词 。 因此,您需要对第一个进行分组,最好使用非捕获组,并从word删除一些单词边界(在指定的上下文中是多余的): String rgx ="\\b(?:addAction|intentFilter)\\b\\s* ...
-
迭代包含正则表达式的javascript对象变量(iterate over javascript object variables containing regex expressions)[2024-03-15]
将其更改为: var formats = { AUS:/^\D*0(\D*\d){9}\D*$/, UK: /^\D*0(\D*\d){9}\D*$/ }; 你拥有它的方式,它的字符串不是正则表达式。 Change it to: var formats = { AUS:/^\D*0(\D*\d){9}\D*$/, UK: /^\D*0(\D*\d){9}\D*$/ }; The way you have it, it's strings not regular expressio ... -
你可以试试 df['dates'] = df['text'].str.extract('.*?(\d+/\d+/?\d*).*?') text dates 0 My birthday is 10/23/89. 10/23/89 1 Christmas is 12/25. 12/25 2 Thanksgiving of 11/2008 was th ...
-
多个辅音的正则表达式(Regex for multiple Consonants)[2024-03-20]
(([b-df-hj-np-tv-z])(?!\2)){3} http://gskinner.com/RegExr/?2vtnt 编辑 这种模式有一个边缘案例,如果它是由相同的最后一个辅音进行的,就会失败。 例如, xyzz应匹配xyz但不匹配。 这将是一个更准确的模式。 (([b-df-hj-np-tv-z])(?!\2)){2}[b-df-hj-np-tv-z] (([b-df-hj-np-tv-z])(?!\2)){3} http://gskinner.com/RegExr/?2vtnt Edit T ...