GNU的C++代码书写规范,C语言之父Dennis Ritchie亲自修订

C++ Standard Library Style Guidelines  DRAFT 1999-02-26
-------------------------------------

This library is written to appropriate C++ coding standards.  As such,
it is intended to precede the recommendations of the GNU Coding
Standard, which can be referenced here:

http://www.gnu.ai.mit.edu/prep/standards_toc.html

ChangeLog entries for member functions should use the
classname::member function name syntax as follows:

1999-04-15  Dennis Ritchie  <dr@att.com>

* src/basic_file.cc (__basic_file::open): Fix thinko in
_G_HAVE_IO_FILE_OPEN bits.

Notable areas of divergence from what may be previous local practice
(particularly for GNU C) include:

01. Pointers and references
  char* p = "flop";
  char& c = *p;
     -NOT-
  char *p = "flop";  // wrong
  char &c = *p;      // wrong
 
    Reason: In C++, definitions are mixed with executable code.  Here,      
    p          is being initialized, not *p.  This is near-universal
            practice among C++ programmers; it is normal for C hackers
            to switch spontaneously as they gain experience.

02. Operator names and parentheses
  operator==(type)
     -NOT-
  operator == (type)  // wrong
    
    Reason: The == is part of the function name.  Separating
            it makes the declaration look like an expression.

03. Function names and parentheses
  void mangle()
     -NOT-
  void mangle ()  // wrong

     Reason: no space before parentheses (except after a control-flow
     keyword) is near-universal practice for C++.  It identifies the
     parentheses as the func
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
gnuradio是一个开源的无线电软件开发工具包,它提供了许多实用的库和工具,用于设计和实现软件定义无线电系统。在gnuradio中,低通滤波器(Low Pass Filter)是一种常用的信号处理工具,用于滤除高频部分,只保留低频成分。 在gnuradio中实现低通滤波器可以使用C语言编写代码。下面是一个简单的gnuradio低通滤波器的C代码示例: ```c #include <stdio.h> #include <gnuradio/filter/firdes.h> #include <gnuradio/filter/fft_filter.h> int main() { const float cutoff_freq = 1000.0; // 截止频率 const float sampling_rate = 2000.0; // 采样率 const int num_taps = 51; // 滤波器阶数(或系数个数) float taps[num_taps]; // 滤波器系数数组 // 使用gnuradio的firdes库函数设计低通滤波器 gr::filter::firdes::low_pass(num_taps, sampling_rate, cutoff_freq, gr::filter::firdes::WIN_HAMMING, taps); // 创建低通滤波器对象 gr::filter::fft_filter<float, float> lpf(num_taps, taps); // 打印滤波器系数 printf("滤波器系数:"); for (int i = 0; i < num_taps; i++) { printf("%.6f ", taps[i]); } printf("\n"); return 0; } ``` 以上代码使用gnuradio的`gr::filter::firdes::low_pass`函数设计了一个51阶的低通滤波器。`low_pass`函数根据指定的采样率、截止频率和窗口类型生成滤波器系数。然后,通过`gr::filter::fft_filter`类创建一个低通滤波器对象,并将滤波器系数传递给该对象。 上述代码中的`printf`语句用于打印滤波器系数。你可以根据需要将滤波器系数用于处理信号,进而实现信号的低通滤波效果。 当然,这只是一个简单的示例,实际应用中可能还需要添加其他相关配置和操作,具体实现方式可能会有所不同。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

myan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值