File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -609,13 +609,28 @@ impl Config {
609
609
/// Run the compiler, returning the macro-expanded version of the input files.
610
610
///
611
611
/// This is only relevant for C and C++ files.
612
+ ///
613
+ /// # Panics
614
+ /// Panics if more than one file is present in the config, as macro
615
+ /// expansion only makes sense for a single file.
616
+ ///
617
+ /// # Example
618
+ /// ```no_run
619
+ /// gcc::Config::new()
620
+ /// .file("src/foo.c")
621
+ /// .expand()
622
+ /// ```
612
623
pub fn expand ( & self ) -> Vec < u8 > {
613
624
let compiler = self . get_compiler ( ) ;
614
625
let mut cmd = compiler. to_command ( ) ;
615
626
for & ( ref a, ref b) in self . env . iter ( ) {
616
627
cmd. env ( a, b) ;
617
628
}
618
629
cmd. arg ( compiler. family . expand_flag ( ) ) ;
630
+
631
+ assert_eq ! ( self . files. len( ) , 1 ,
632
+ "Expand may only be called for a single file" ) ;
633
+
619
634
for file in self . files . iter ( ) {
620
635
cmd. arg ( file) ;
621
636
}
You can’t perform that action at this time.
0 commit comments