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


+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.

  • Is there a way for me to improve the question to make it more compelling?
    – otyn
    Commented Oct 19, 2018 at 9:26

1 Answer 1


Try this instead:

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

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.

  • I've picked up lots of useful things from scimax, but I hadn't seen that before.
    – otyn
    Commented Oct 19, 2018 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.