The problem
===========

I'm currently writing notes on C++ classes. Sometimes I annotate what I shouldn't do (because they cause compilation errors) so it would be really helpful if I could automatically insert compilation errors in the `#+RESULTS` section of source code blocks.

Consider the following example: I would like the following code block to produce

```
#+begin_src cpp
class A {
  static int n = 0;
};

int main() { return 0; }
#+end_src

```

this `#+RESULTS` code block

```
#+RESULTS:
#+begin_example
/tmp/babel-NYqDkg/C-src-HslBxN.cpp:11:14: error: ISO C++ forbids in-class initialization of non-const static member ‘A::n’
   11 |   static int n = 0;
      |              ^
#+end_example

```

Additional context
==================

In `sh` source code blocks, I can accomplish a similar behavior by using the following header arguments

```
#+begin_src sh :prologue "exec 2>&1" :epilogue ":"
ls "this path doesn't exist"
#+end_src

#+RESULTS:
#+begin_example
ls: cannot access "this path doesn't exist": No such file or directory
#+end_example

```