0

Is there an replacement for

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

so that i can do sth like this:

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

(the way i go when i don't use any makefile)

on windows i did it this way:

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

because regular expressions seem not to work or I wasn't able to find a way to make them work...

Could you tell me how to do it on windows?

3
  • 2
    For a start you're not using a regular expression but regular wildcards. ** would not be a regular expression as it's a quantifier and quantifying "any number of items any number of items" doesn't make a whole lot of sense. On Windows you could use src/*.cpp. What you're missing is a wildcards to mean "every cpp file in every directory". Usually you would use a script for that. In this case you could use a PowerShell script that collects the files and builds a string which you could use as the parameter for GCC.
    – Seth
    Commented Oct 17, 2016 at 11:01
  • Naja indirekt ist auch * ein regulärer Ausdruck, da die Sprache die genau Sigma* akzeptiert damit impliziert wird.
    – baxbear
    Commented Oct 17, 2016 at 11:56
  • If you feel happy with that definition it's fine. But if you're not able to do ls ./[a-Z]{4}/.* it doesn't meet the technical definition of a regular expression and the ** would still be a violation/nonsense of what's usually accepted as a regular expression in technical systems. In addition in my ls example you probably would need to escape the first dot to make it a literal rather than any character.
    – Seth
    Commented Oct 17, 2016 at 13:02

1 Answer 1

0

Depending on whenever you can use absolute paths you could use the following piece of PowerShell Code:

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

You might be able to shorten this to:

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

This isn't exactly as short or readable as your Linux equivalent but the closest I can think of to get to your desired result.

If your src has a flat hierarchy you could use:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .