1

I would like to compile my java program using gcc rather than using javac Because it can give out a more detail information compared to javac.

In my startup configuration. I use "make" to help me compile my program so I have to set the compiler for "make" first

I use this command to set the compiler to gcc automatically when the filetype is java. autocmd FileType java compiler gcc

But when I tried to compile my program using "make" It give out a lot of message that I don't understand, and it cannot compile the program.

However, When I first set the compiler to javac,then set it to gcc later. "make" works!!

  1. In my startup config : autocmd FileType java compiler javac
  2. When i am editing the file, :compiler gcc

Then I can compile my java program using make with gcc compiler

I don't know what the problem it is. Can I automatically set compiler to gcc instead of setting it later when editing the file ??

code4j
  • 4,208
  • 5
  • 34
  • 51

1 Answers1

1

Try autocmd FileType java set makeprg=gcc in your .vimrc.

Balint
  • 1,405
  • 1
  • 9
  • 12
  • Thx for your help, It told me that I miss the gcc compiler for java But now I find another problem when I use the second setting .vimrc : autocmd FileType java compiler javac When i am editing the file, :compiler gcc I will never use gcc as my compiler I still use javac as my compiler. But It give out a more detail information in quick fix list – code4j Jun 08 '12 at 19:59
  • I'm sorry, I'm not sure I have exactly understood your new problem. – Balint Jun 11 '12 at 10:14
  • In my .vimrc right now I set javac automatically for "make" But the error messages in quick fix are poor A single line is for one error The new problem I discovered is that: Even I set :compiler gcc when i am editing the file I never use gcc as my compiler. The MacVim still use javac to compile my program But quick fix will show more detailed information rather than a single line for one error Thx :) – code4j Jun 12 '12 at 07:10