I have been asked to port some Fortran 90 code from Linux to Windows 10. The code makes use of ANSI terminal commands to colour text. I have found that this does not seem to be supported by default in windows 10 terminals.
Would anyone be able to suggest a means to enable this using F90 / C code?
I think that I may need to switch ENABLE_VIRTUAL_TERMINAL_PROCESSING on. I found some code that appears to do this. I have pasted it below. I should point out that my understanding of C is rather elementary. I can get the pasted code to work using the gcc compiler but get several errors - pasted below code - when using pgcc or pgfortran. Can anyone advise what I can do to get this to work using pg compilers please?
Apologies if this is rather simple…
#include <stdio.h>
#include <windows.h>
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
int main(int argc, char** argv) {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwMode = 0;
GetConsoleMode(hOut, &dwMode);
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(hOut, dwMode);
printf("\x1b[101;93m Testing\x1b[0m\n");
return 0;
}
pgcc c_code.c
PGC-W-0114-More than one type specified (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\WinNT.h: 435)
PGC-W-0143-Useless typedef declaration (no declarators present) (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\WinNT.h: 435)
PGC-W-0114-More than one type specified (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\commdlg.h: 734)
PGC-W-0143-Useless typedef declaration (no declarators present) (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\commdlg.h: 734)
PGC-W-0043-Redefinition of symbol, LPUINT (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\imm.h: 45)
PGC/x86-64 Windows 18.10-1: compilation completed with warnings
pgfortran c_code.c
PGC-W-0114-More than one type specified (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\WinNT.h: 435)
PGC-W-0143-Useless typedef declaration (no declarators present) (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\WinNT.h: 435)
PGC-W-0114-More than one type specified (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\commdlg.h: 734)
PGC-W-0143-Useless typedef declaration (no declarators present) (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\commdlg.h: 734)
PGC-W-0043-Redefinition of symbol, LPUINT (D:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/um\imm.h: 45)
PGC/x86-64 Windows 18.10-1: compilation completed with warnings
pgfortran5dzG2lkdMQDjJ.obj : error LNK2005: main already defined in f90main.obj
f90main.obj : error LNK2019: unresolved external symbol MAIN_ referenced in function main
c_code.exe : fatal error LNK1120: 1 unresolved externals