[flang-commits] [flang] GETLOG runtime and extension implementation: get login username (PR #70917)

David Truby via flang-commits flang-commits at lists.llvm.org
Thu Nov 9 08:37:30 PST 2023


================
@@ -14,6 +14,37 @@
 #include "flang/Runtime/descriptor.h"
 #include <cstdlib>
 #include <limits>
+#include <string.h>
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include <windows.h>
+
+#include <lmcons.h> // UNLEN=256
+#include <wchar.h> // wchar_t cast to LPWSTR
+#pragma comment(lib, "Advapi32.lib") // Link Advapi32.lib for GetUserName
+
+static inline char *getlogin() {
+  static char username[UNLEN + 1];
----------------
DavidTruby wrote:

I don't think we want a function-level static variable here; every windows flang program will have to have an array of size UNLEN+1 allocated all the time

https://github.com/llvm/llvm-project/pull/70917


More information about the flang-commits mailing list