gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
Main.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include <stdlib.h>
7 #include "GmshGlobal.h"
8 
9 #if defined(WIN32) && !defined(__CYGWIN__)
10 
11 // in order to handle non-ASCII command line arguments on Windows, use wmain()
12 // instead of main() (we could also use main() and retrieve the "wide" args with
13 // GetCommandLineW() later on, but this would have side-effects on the flow for
14 // e.g. initializing the api); using wmain() with the mingw compilers requires
15 // adding the "-municode" linker flag
16 
17 #include <windows.h>
18 #include <wchar.h>
19 
20 static char *toUTF8(wchar_t *src)
21 {
22  if(!src) return nullptr;
23  size_t srclen = wcslen(src);
24  int len = WideCharToMultiByte(CP_UTF8, 0, src, srclen, 0, 0, nullptr, nullptr);
25  char *out = new char[len + 1];
26  if(out) {
27  WideCharToMultiByte(CP_UTF8, 0, src, srclen, out, len, nullptr, nullptr);
28  out[len] = '\0';
29  }
30  return out;
31 }
32 
33 int wmain(int argc, wchar_t *wargv[], wchar_t *envp[])
34 {
35  char **argv = new char*[argc + 1];
36  for(int i = 0; i < argc; i++)
37  argv[i] = toUTF8(wargv[i]);
38  argv[argc] = nullptr;
39 
40 #else
41 
42 int main(int argc, char *argv[])
43 {
44 
45 #endif
46 
47 #if defined(HAVE_FLTK)
48  return GmshMainFLTK(argc, argv);
49 #else
50  return GmshMainBatch(argc, argv);
51 #endif
52 }
GmshMainFLTK
GMSH_API int GmshMainFLTK(int argc, char **argv)
Definition: GmshGlobal.cpp:505
main
int main(int argc, char *argv[])
Definition: Main.cpp:42
GmshGlobal.h
GmshMainBatch
GMSH_API int GmshMainBatch(int argc, char **argv)
Definition: GmshGlobal.cpp:485