Skip to content

[bug] defines 值含空格时未转义,命令行被拆散(-DX="long long" → 孤立 long 参数) #234

Description

@Sunrisepeak

现象

[build].flags 条目(或推测任何 defines 通道)中,值含空格的 define 未被引号保护地拼进编译命令行,空格后的部分被 g++ 当作独立的输入文件:

g++: warning: long: linker input file unused because linking not done
g++: error: long: linker input file not found: No such file or directory

最小复现(mcpp 0.0.95,linux-x86_64)

[package]
name = "repro2"
version = "0.1.0"

[build]
flags = [{ glob = "src/**", defines = ["T=long long"] }]

[targets.repro2]
kind = "bin"
main = "src/main.cpp"
// src/main.cpp
#ifndef T
#error T undefined
#endif
typedef T mytype;
int main(){ mytype v = 0; return (int)v; }

mcpp build → 上述报错(期望:-D"T=long long" 或等效转义,构建成功)。

真实场景

OpenCV 5.0 CMake 构建对 core 模块传
-DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE="long long"——把 OpenCV 5.0 做成全源码直编 compat 包时无法忠实复刻该编译面。当前 workaround:把含空格 define 改写成转发 stub 顶部的 #define 文本行。

期望

命令行装配时对含空格/特殊字符的 flag 值做转义(ninja $ 转义 + shell 引号),cflags/cxxflags/defines 各通道一致处理。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions