lib: Expose SOURCE_LOCATOR as OVS_SOURCE_LOACATOR
[cascardo/ovs.git] / include / openvswitch / util.h
index 58c2b59..b0b9935 100644 (file)
 
 #include <openvswitch/version.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void ovs_set_program_name__(const char *name, const char *version,
                             const char *date, const char *time);
 
@@ -28,4 +32,16 @@ void ovs_set_program_name__(const char *name, const char *version,
 const char *ovs_get_program_name(void);
 const char *ovs_get_program_version(void);
 
+/* Expands to a string that looks like "<file>:<line>", e.g. "tmp.c:10".
+ *
+ * See http://c-faq.com/ansi/stringize.html for an explanation of OVS_STRINGIZE
+ * and OVS_STRINGIZE2. */
+#define OVS_SOURCE_LOCATOR __FILE__ ":" OVS_STRINGIZE(__LINE__)
+#define OVS_STRINGIZE(ARG) OVS_STRINGIZE2(ARG)
+#define OVS_STRINGIZE2(ARG) #ARG
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif