Internals: Use standard function for include guards. No functional change intended.

This commit is contained in:
Wilson Snyder
2019-12-23 19:00:17 -05:00
parent 5c59fde92e
commit 5089f997cc
7 changed files with 45 additions and 22 deletions
+12
View File
@@ -25,6 +25,7 @@
#include "V3File.h"
#include "V3Os.h"
#include "V3PreShell.h"
#include "V3String.h"
#include "V3Ast.h"
#include <cerrno>
@@ -942,6 +943,17 @@ void V3OutFile::putsForceIncs() {
}
}
void V3OutCFile::putsGuard() {
UASSERT(!m_guard, "Already called putsGuard in emit file");
m_guard = true;
string var = VString::upcase(string("_") + V3Os::filenameNonDir(filename()) + "_");
for (string::iterator pos = var.begin(); pos != var.end(); ++pos) {
if (!isalnum(*pos)) *pos = '_';
}
puts("\n#ifndef " + var + "\n");
puts("#define " + var + " // guard\n");
}
//######################################################################
// VIdProtect