Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Failing to emit line directive if included file has a #if or #define on the first line

オープン
#222 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
compilers

調査の方向性

提供された入力 a.cpp、if.h、def.h を default_preprocessing_hooks と eat_whitespace の両方を使って問題を再現します。次に、最初に出力される内容が単一の #if、#ifdef、または #define に続くインクルードファイルについて、Wave の行ディレクティブ処理を追跡します。出力に if.h と def.h に対する期待される #line エントリが含まれ、既存の複数ディレクティブの動作が引き続き正しいことを確認できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Wave is not emitting the line directive if the first line in the included file is a #if or #ifdef that evaluates true and has content in its block. Likewise, it won't emit the line directive if the first line is a #define. This issue only occurs if there are not multiple #define or #if occurring on subsequent lines.
When using default_preprocessing_hooks, the above applies if the #if/#ifdef/#define is the first non-empty line or non-comment line. Essentially, if the directive immediately precedes the first content emitted from the included file. With eat_whitespace, the directive must be on the very first line of the include file to exhibit the issue.

Not sure if I've explained it very well, but I think an example will help better demonstrate the issue.

Example:
a.cpp

#include "if.h"
#include "def.h"
test

if.h

#if 1 //This must be on the first line for eat_whitespace, can be on 2nd, 3rd etc, for default_preprocessing_hooks as long as it's whitespace before it
if_h
#endif

def.h

#define A
def_h

Resulting preprocessed file:
a.preproc


if_h

def_h

Expected output:

#line 2 "if.h"
if_h
#line 2 "def.h"
def_h

As mentioned, the line directives do get emitted correctly if the include file is something like this:

#define A
#define B
content

So it's only occurring when there's a single directive at the beginning.

主要言語
C++
スター
29
フォーク
56
平均マージ
1日 15時間
マージ済み PR(30日)
4

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/wave のほかの issue

boostorg/wave の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。