Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C/C++ Watcher (cw)

CI npm

cw is a simple CLI tool that automatically compiles and runs C/C++ files whenever they are modified, saving you time and effort.

Installation

To install cw globally using npm, run:

npm install -g c_cpp-watcher

Prerequisites:
Make sure you have a C/C++ compiler installed (gcc for C, g++ for C++). You can check by running:

gcc --version
g++ --version

Usage

cw [options] <file...> [compiler flags] [-- program arguments]
cw main.cpp                       # watch, compile and run
cw main.cpp -Wall -std=c++17      # pass flags to the compiler
cw main.cpp util.cpp -I include   # compile several files together
cw main.c -- --input data.txt     # pass arguments to your program
cw --compiler clang++ main.cpp    # use a different compiler

Everything between the source files and -- goes to the compiler. Everything after -- goes to your program, so a flag like --verbose reaches your argv instead of being handed to the compiler.

  • The program recompiles and restarts whenever a watched file changes.
  • Headers are watched too. cw asks the compiler which headers your sources include, so editing utils.h rebuilds main.cpp.
  • When the program isn't running, type rs to restart it or q to quit.
  • Each build reports how long it took, and each run reports the exit code.

Options

cw's own options go before the source files, so they can never be mistaken for a compiler flag like -w or -v.

Option Description
-h, --help Show usage
--version Show the version
--compiler <bin> Compiler to use (defaults to g++/gcc, or $CXX/$CC)
--out <path> Executable to write (-o among the compiler flags works too)
--watch <path> Also watch this file or directory, repeatable
--no-run Compile on change without running
--clear Clear the screen before each rebuild

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages