compile c problem in emacs (ubuntu)

Posted by user565739 on Stack Overflow See other posts from Stack Overflow or by user565739
Published on 2011-01-07T06:32:18Z Indexed on 2011/01/07 7:53 UTC
Read the original article Hit count: 152

Filed under:
|

I wrote a very simple program like: ( sorry, I typed the code in the right way, but the display is wired. How could I fix it?)

#include <stdio.h>
int main( void )
{
   int i;

   for ( i = 0; i <= 10; i++ ) {
      printf( "%d hello!\n", i);
   }
   return 0;
}

Usually, I compile c program in terminal with the command

cc -o xxx xxx.c

So in Emacs, when I type M-x compile, I change make -k to cc -o. But I got error like

cc: argument to '-o' is missing

What's the problem?

If I use make, then I still got error

No targets specified and no makefiles found.

Finally, if the above problem is fixed, how could I define a custom hotkey for compile? I have already know how to do something like

global-set-key [f8] 'goto-line

But I don't know to set a hotkey for an action only for c-mode.

© Stack Overflow or respective owner

Related posts about emacs

Related posts about emacs23