0

I've started on Learn C The Hard Way and want to collect my work in org mode. Executing

rm ex1 && CFLAGS="-Wall" make ex1

in the terminal returns

cc -Wall ex1.c -o ex1 ex1.c: In function ‘main’: ex1.c:3:3: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration] puts("Hello world."); ^~~~

but executing the source block

+BEGIN_SRC sh :results output :dir lcthw/ rm ex1 && CFLAGS="-Wall" make ex1 +END_SRC

renders

+RESULTS: : cc -Wall ex1.c -o ex1

without the warnings.

Anyway I can include the warnings in the results of the source block? It is very relevant for working with C.

Feel like I have tried most (all?) results flags without success. Also looked into this question, but it specifies as python specific, so not sure if it should work.

otyn
  • 83
  • 9

1 Answers1

1

Try this instead:

#+BEGIN_SRC sh :results output :dir lcthw/
  exec 2>&1
  rm ex1 && CFLAGS="-Wall" make ex1
  :
#+END_SRC

There are some other options described at http://kitchingroup.cheme.cmu.edu/blog/2015/01/04/Redirecting-stderr-in-org-mode-shell-blocks/, that may be more appealing. This worked for me.

John Kitchin
  • 11,555
  • 1
  • 19
  • 41