Windows 上相當於 unix 正規表示式

Windows 上相當於 unix 正規表示式

有替代品嗎

**/*.*
**/*.cpp

這樣我就可以這樣做:

gcc -std=c++14 -I ./include/ -o ./bin/main ./src/**/*.cpp

(當我不使用任何 makefile 時我的方式)

在Windows上我是這樣做的:

gcc -std=c++14 -I include -o bin/main src/main.cpp src/Sth.cpp src/SthEl.cpp

因為正規表示式似乎不起作用,或者我無法找到一種方法讓它們起作用...

你能告訴我如何在windows上做到這一點嗎?

答案1

根據何時可以使用絕對路徑,您可以使用以下 PowerShell 程式碼:

$files = (Get-ChildItem -Recurse -Path ./src *.cpp | %{echo $_.FullName}) -Join " "
gcc -std=c++14 -I include -o bin/main $files

您也許可以縮短為:

gcc -std=c++14 -I include -o bin/main ((Get-ChildItem -Recurse -Path ./src *.cpp | %{echo $_.FullName}) -Join " ")

這並不像您的 Linux 等效項那麼短或可讀,但我能想到最接近您想要的結果。

如果你src有一個扁平的層次結構,你可以使用:

gcc -std=c++14 -I include -o bin/main src/*.cpp

相關內容