5

I try to globally set header properties for C++ source examples, with no success. I would have expected that the following works

 #+PROPERTY: header-args:C++ :var x=1.0

What did work is using general header args property:

 #+PROPERTY: header-args :var x=1.1

Also specific property drawer worked:

* Resources
:PROPERTIES:
:header-args:C++: :var x=1.2
:END:

And of course using plain old header arguments works:

#+header: :exports results
#+header: :includes <iostream>
#+header: :var x=1.3
#+begin_src C++
std::cout << x;
#+end_src

Could that be a bug or am I doing something wrong?

1 Answer 1

2

I found out, that I have to use cpp instead of C++ to get it working:

#+PROPERTY: header-args:cpp :var x=1.0

#+header: :exports results
#+header: :includes <iostream>
#+begin_src cpp
std::cout << x;
#+end_src

Reason: A single plus behind the property name means: Append the following property values to the already set ones. So the line

 #+PROPERTY: header-args:C++ :var x=1.0

is interpreted as: Append the value :var x=1.0 to the value of property header-args:C+.

Your Answer

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

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