[gnote] validate formats at build time.



commit 67bb723276e892eb00fb54432e157edf3385f733
Author: Hubert Figuiere <hub figuiere net>
Date:   Thu May 28 00:19:20 2009 -0400

    validate formats at build time.
---
 src/Makefile.am     |    1 +
 src/base/macros.hpp |   39 +++++++++++++++++++++++++++++++++++++++
 src/debug.hpp       |   26 +++++---------------------
 3 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index fbcad23..53d5df0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,6 +71,7 @@ endif
 
 libgnote_a_SOURCES = \
 	base/singleton.hpp \
+	base/macros.hpp \
 	sharp/addinstreemodel.hpp sharp/addinstreemodel.cpp \
 	sharp/datetime.hpp sharp/datetime.cpp \
 	sharp/dynamicmodule.hpp sharp/dynamicmodule.cpp \
diff --git a/src/base/macros.hpp b/src/base/macros.hpp
new file mode 100644
index 0000000..fc75419
--- /dev/null
+++ b/src/base/macros.hpp
@@ -0,0 +1,39 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+
+#ifndef __BASE_MACROS_
+#define __BASE_MACROS_
+
+
+#if __GNUC__
+#define _PRINTF_FORMAT(f,a) \
+    __attribute__ ((format (printf, f, a)));
+#else
+#define _PRINTF_FORMAT(f,a)
+#endif
+
+#endif
diff --git a/src/debug.hpp b/src/debug.hpp
index eced7cc..d1d857e 100644
--- a/src/debug.hpp
+++ b/src/debug.hpp
@@ -17,25 +17,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/*
- * niepce - utils/debug.h
- *
- * Copyright (C) 2007 Hubert Figuiere
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
 #ifndef __UTILS_DEBUG_H__
 #define __UTILS_DEBUG_H__
 
@@ -46,6 +27,7 @@
 #endif
 
 #include <assert.h>
+#include "base/macros.hpp"
 
 namespace utils {
 
@@ -74,7 +56,8 @@ namespace utils {
    * @param fmt the formt string, printf style
    * @param func the func name
    */
-  void dbg_print(const char* fmt, const char* func, ...);
+  void dbg_print(const char* fmt, const char* func, ...)
+    _PRINTF_FORMAT(1,3);
 
   /** assert 
    * @param condvalue the value of the assert, true, assert
@@ -91,7 +74,8 @@ namespace utils {
    * @param fmt the formt string, printf style
    * @param func the func name
    */
-  void err_print(const char *fmt, const char* func, ...);
+  void err_print(const char *fmt, const char* func, ...)
+    _PRINTF_FORMAT(1,3);
 
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]