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.

  • Is there a way for me to improve the question to make it more compelling? – otyn Oct 19 '18 at 9:26
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.

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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