From c73c88033d42158a798c97c6bf3114d28e02e62b Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Tue, 15 Oct 2024 12:00:51 +0200 Subject: [PATCH] hashlib: only include in one place --- kernel/hashlib.h | 2 ++ kernel/yosys_common.h | 3 +-- passes/cmds/rename.cc | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 2e4c49176..b4d82f80a 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -34,6 +34,8 @@ namespace hashlib { * Hashlib doesn't know how to hash silly Yosys-specific types. * Hashlib doesn't depend on Yosys and can be used standalone. * Please don't use hashlib standalone for new projects. + * Never directly include kernel/hashlib.h in Yosys code. + * Instead include kernel/yosys_common.h * * The hash_ops type is now always left to its default value, derived * from templated functions through SFINAE. Providing custom ops is diff --git a/kernel/yosys_common.h b/kernel/yosys_common.h index 52f7f5f96..9370de330 100644 --- a/kernel/yosys_common.h +++ b/kernel/yosys_common.h @@ -134,8 +134,7 @@ YOSYS_NAMESPACE_BEGIN // Note: All headers included in hashlib.h must be included // outside of YOSYS_NAMESPACE before this or bad things will happen. #ifdef HASHLIB_H -# undef HASHLIB_H -# include "kernel/hashlib.h" +# error You've probably included hashlib.h under two namespace paths. Bad idea. #else # include "kernel/hashlib.h" # undef HASHLIB_H diff --git a/passes/cmds/rename.cc b/passes/cmds/rename.cc index 3f8d807b3..fe8b4a444 100644 --- a/passes/cmds/rename.cc +++ b/passes/cmds/rename.cc @@ -20,7 +20,6 @@ #include "kernel/register.h" #include "kernel/rtlil.h" #include "kernel/log.h" -#include "kernel/hashlib.h" USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN