首页 \ 问答 \ “无用类型限定符”错误(“useless type qualifier” error)

“无用类型限定符”错误(“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
更新时间:2023-08-25 09:08

最满意答案

如果您使用散列而不是数组来组织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.

相关问答

更多
  • 如果您只是想过滤掉负数列表中以单词开头的字符串,请在模式开头处使用负向前视图,并使用替代方式来覆盖该单词列表: ^(?!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 ...
  • >>> 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.'] ...
  • 我会使用一个简单的函数而不是正则表达式,因为在这种情况下,需要一个复杂的正则表达式。 /** * * 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 ...
  • 如果您使用散列而不是数组来组织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* ...
  • 将其更改为: 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 ...
  • (([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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)