Small Script For Fixing #include Paths
I’ve been spending some time trying to port a game written in C++ for windows to BSD/Linux.
One of the things that usually cause issues is that most Windows compilers accept include statements that looks like this
#include path\to\fileBut GCC prefers it like so
#include path/to/fileInstead of manually going through each file to fix this issue i wrote a quick bourne shell script using grep and sed
This script will affect all files that are in the current folder and down.
It does a rough search looking for all files ending with .h or .cpp and does an in file replace of all back slashes to front slashes where the line begins with #include
This is in no way tested enough, no warranty given. Make sure to only use it on folders that have a backup of some sort.
#!/bin/sh
for f in $(find ./ | grep -E ".*([.]cpp$)|([.]h$)")
do
sed -i '/^\(#include\).*/s/\\/\//g' $f
done