2

So I am entering source code into org documents by using source code blocks such as:

#+BEGIN_SRC C++
  #include <iostream>

  using namespace std;

  int main() {
      cout << "Hello World" << endl;
      return 0;
  }

#+END_SRC

Notice that the language tag is 'C++'. When I use uppercase 'C', there is no syntax highlighting but C-c C-c will allow me to evaluate the code block properly. However, if I try to edit the block by doing C-c ' then I get the error "No such language mode: C++-mode".

If I switch the language tag to 'c++', then I get syntax highlighting and I am able to use C-c ' to edit the source block but then if I try C-c C-c to evaluate the source block I get the error "No org-babel-execute function for c++!"

I have looked in the ob-c.el and org-src.el source code and I think I have found where I could fix it. Although I don't want to depart from the official source I wanted to see if I was on the right track. Unfortunately, I can't figure out how to load those changes once I have made them, or maybe it is that the change didn't do what I thought =) All I did was modify the code in the emacs/lisp directory and delete the .elc version of the file in the hopes that it would get re-compiled the next time emacs started.

Is this a true bug or am I missing something? This is version 24.3.1

Thanks!

1 Answer 1

2

Looking a bit more closely in the ob-c.el code and it looks like it will also respond to 'cpp' which also works for org-src.el. So using the 'cpp' tag gives syntax highlighting and source execution.

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.