+-

有没有办法配置clang格式工具跳过我的Qt :: connect函数调用?我的构造函数中有几个连接看起来像这样:
connect( m_Job, SIGNAL( error( const QString&, const QString& ) ), this, SLOT( onError( const QString&, const QString& ) ) );
connect( m_Job, SIGNAL( message( const QString& ) ), this, SLOT( onMessage( const QString& ) ) );
connect( m_Job, SIGNAL( progress( int, int ) ), this, SLOT( onProgress( int, int ) ) );
但是在我运行格式化工具后,它会降低可读性:
connect( m_Job, SIGNAL( error(const QString&, const QString&)), this, SLOT( onError(const QString&, const QString&)) );
connect( m_Job, SIGNAL( message(const QString&)), this, SLOT( onMessage(const QString&)) );
connect( m_Job, SIGNAL( progress(int, int)), this, SLOT( onProgress(int, int)) );
最佳答案
使用// clang-format off和// clang-format on使其跳过代码段.
// clang-format off
// Don't touch this!
connect( m_Job, SIGNAL( error( const QString&, const QString& ) ), this, SLOT( onError( const QString&, const QString& ) ) );
connect( m_Job, SIGNAL( message( const QString& ) ), this, SLOT( onMessage( const QString& ) ) );
connect( m_Job, SIGNAL( progress( int, int ) ), this, SLOT( onProgress( int, int ) ) );
// clang-format on
// Carry on formatting
点击查看更多相关文章
转载注明原文:如何使clang-format跳过c代码段 - 乐贴网