Browse Source

ob-C.el: Fix missing C, C++ declaration

* lisp/ob-C.el (org-babel-C-utility-header-to-C): Add declaration of
  strcmp() for C and C++.

* testing/examples/ob-C-test.org (Simple tests): Remove a spurious \n
  new line.
tbanelwebmin@free.fr 4 năm trước cách đây
mục cha
commit
9e8215f4a5
2 tập tin đã thay đổi với 9 bổ sung3 xóa
  1. 8 2
      lisp/ob-C.el
  2. 1 1
      testing/examples/ob-C-test.org

+ 8 - 2
lisp/ob-C.el

@@ -4,6 +4,7 @@
 
 ;; Author: Eric Schulte
 ;;      Thierry Banel
+;; Maintainer: Thierry Banel
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: https://orgmode.org
 
@@ -425,7 +426,12 @@ of the same value."
 into a column number."
   (pcase org-babel-c-variant
     ((or `c `cpp)
-     "int get_column_num (int nbcols, const char** header, const char* column)
+     (concat
+      (if (eq org-babel-c-variant 'c)
+          "extern "
+	"extern \"C\" ")
+      "int strcmp (const char *, const char *);
+int get_column_num (int nbcols, const char** header, const char* column)
 {
   int c;
   for (c=0; c<nbcols; c++)
@@ -433,7 +439,7 @@ into a column number."
       return c;
   return -1;
 }
-")
+"))
     (`d
      "int get_column_num (string[] header, string column)
 {

+ 1 - 1
testing/examples/ob-C-test.org

@@ -159,6 +159,6 @@ void main()
       writef ("%s ", tinomogen[i][j]);
     writeln();
   }
-  writefln ("Friday %s\n", tinomogen_h(4,"day"));
+  writefln ("Friday %s", tinomogen_h(4,"day"));
 }
 #+end_src