From ed3d15bc669c8ea2c2acbdec6a1da980e8006a92 Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.cc> Date: Mon, 23 Jun 2014 13:50:35 +0200 Subject: Use C-style comments instead of C++-style comments --- docs/development/submitting-patches.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'docs/development/submitting-patches.rst') diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst index b7f43283..3eea1dd3 100644 --- a/docs/development/submitting-patches.rst +++ b/docs/development/submitting-patches.rst @@ -82,9 +82,9 @@ Don't name parameters: .. code-block:: c - // Good + /* Good */ long f(long); - // Bad + /* Bad */ long f(long x); ...unless they're inside a struct: @@ -101,16 +101,16 @@ Include ``void`` if the function takes no arguments: .. code-block:: c - // Good + /* Good */ long f(void); - // Bad + /* Bad */ long f(); Wrap lines at 80 characters like so: .. code-block:: c - // Pretend this went to 80 characters + /* Pretend this went to 80 characters */ long f(long, long, int *) @@ -118,9 +118,9 @@ Include a space after commas between parameters: .. code-block:: c - // Good + /* Good */ long f(int, char *) - // Bad + /* Bad */ long f(int,char *) Values set by ``#define`` should be assigned the appropriate type. If you see -- cgit v1.2.3 From 0d1122def98a7b41c65946b638edeb310f93479a Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.cc> Date: Mon, 23 Jun 2014 13:50:51 +0200 Subject: Add note about using C-style vs C++-style comments --- docs/development/submitting-patches.rst | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'docs/development/submitting-patches.rst') diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst index 3eea1dd3..c05f56d1 100644 --- a/docs/development/submitting-patches.rst +++ b/docs/development/submitting-patches.rst @@ -123,6 +123,13 @@ Include a space after commas between parameters: /* Bad */ long f(int,char *) +Use C-style ``/* */`` comments instead of C++-style ``//``: + +.. code-block:: c + + // Bad + /* Good */ + Values set by ``#define`` should be assigned the appropriate type. If you see this: -- cgit v1.2.3 From 0a1d9e17858f0ab5465d3455970f6525607096ba Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.cc> Date: Mon, 23 Jun 2014 14:06:16 +0200 Subject: Add a reference in the style guide --- docs/development/submitting-patches.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs/development/submitting-patches.rst') diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst index c05f56d1..f8c8093c 100644 --- a/docs/development/submitting-patches.rst +++ b/docs/development/submitting-patches.rst @@ -75,6 +75,9 @@ specifying a different backend. C bindings ~~~~~~~~~~ +More information on C bindings can be found in :doc:`the dedicated +section of the documentation `. + When binding C code with ``cffi`` we have our own style guide, it's pretty simple. -- cgit v1.2.3 From 220a98ddfee87e049ddb91229b05e6f9c82a5ddf Mon Sep 17 00:00:00 2001 From: Laurens Van Houtven <_@lvh.cc> Date: Mon, 23 Jun 2014 14:08:27 +0200 Subject: Move C bindings style guide to C bindings document --- docs/development/submitting-patches.rst | 72 --------------------------------- 1 file changed, 72 deletions(-) (limited to 'docs/development/submitting-patches.rst') diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst index f8c8093c..fe2df431 100644 --- a/docs/development/submitting-patches.rst +++ b/docs/development/submitting-patches.rst @@ -78,78 +78,6 @@ C bindings More information on C bindings can be found in :doc:`the dedicated section of the documentation `. -When binding C code with ``cffi`` we have our own style guide, it's pretty -simple. - -Don't name parameters: - -.. code-block:: c - - /* Good */ - long f(long); - /* Bad */ - long f(long x); - -...unless they're inside a struct: - -.. code-block:: c - - struct my_struct { - char *name; - int number; - ...; - }; - -Include ``void`` if the function takes no arguments: - -.. code-block:: c - - /* Good */ - long f(void); - /* Bad */ - long f(); - -Wrap lines at 80 characters like so: - -.. code-block:: c - - /* Pretend this went to 80 characters */ - long f(long, long, - int *) - -Include a space after commas between parameters: - -.. code-block:: c - - /* Good */ - long f(int, char *) - /* Bad */ - long f(int,char *) - -Use C-style ``/* */`` comments instead of C++-style ``//``: - -.. code-block:: c - - // Bad - /* Good */ - -Values set by ``#define`` should be assigned the appropriate type. If you see -this: - -.. code-block:: c - - #define SOME_INTEGER_LITERAL 0x0; - #define SOME_UNSIGNED_INTEGER_LITERAL 0x0001U; - #define SOME_STRING_LITERAL "hello"; - -...it should be added to the bindings like so: - -.. code-block:: c - - static const int SOME_INTEGER_LITERAL; - static const unsigned int SOME_UNSIGNED_INTEGER_LITERAL; - static const char *const SOME_STRING_LITERAL; - Tests ----- -- cgit v1.2.3