]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/CodeTools/TianoTools/Pccts/NOTES.msvc
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / CodeTools / TianoTools / Pccts / NOTES.msvc
CommitLineData
878ddf1f 1\r
2 Microsoft Visual C Stuff\r
3\r
4\r
5[Tom Moog 2-Oct-98\r
6\r
7 Users of Microsoft Visual C++ should download a separate\r
8 ready-to-run zip file from my web site. It contains \r
9 binaries, static library, and a sample project.\r
10]\r
11\r
12[\r
13 Two notes added by Tom Moog 23-Sep-97. I believe the *.dsp and\r
14 *.mak files that were once at the end of this file are now obsolete.\r
15 \r
16 The following MSVC .dsp and .mak files for pccts and sorcerer\r
17 were contributed by Stanislaw Bochnak (S.Bochnak@microtool.com.pl)\r
18 and Jeff Vincent (jvincent@novell.com)\r
19\r
20 PCCTS Distribution Kit\r
21 ----------------------\r
22 pccts/antlr/AntlrMSVC50.dsp\r
23 pccts/antlr/AntlrMSVC50.mak\r
24\r
25 pccts/dlg/DlgMSVC50.dsp\r
26 pccts/dlg/DlgMSVC50.mak\r
27\r
28 pccts/support/genmk/watgenmk.mak\r
29 pccts/support/msvc.dsp\r
30\r
31 Sorcerer Distribution Kit\r
32 -------------------------\r
33 pccts/sorcerer/SorcererMSVC50.dsp\r
34 pccts/sorcerer/SorcererMSVC50.mak\r
35\r
36 pccts/sorcerer/lib/msvc.dsp\r
37\r
38 I do not have an MS based computer. If you discover problems\r
39 please report them so as to save trouble for others in the future.\r
40]\r
41\r
42[\r
43 Modified by Terence Parr (September 1995) to change .C to .cpp\r
44]\r
45\r
46[\r
47 This file contains notes on MSVC for Windows NT console execs by Dave\r
48 Seidel and an explanation of flags etc.. by John Hall; good luck,\r
49 Terence\r
50]\r
51\r
52===============================================================================\r
53Date: Sat, 31 Dec 1994 11:40:36 -0500 (EST)\r
54From: David Seidel <75342.2034@compuserve.com>\r
55\r
56I've succesfully build 1.31b3 with djgpp for DOS and MSVC 2.0 for Windows \r
57NT. The only (minor) problem I had was that GNU make (version 3.71, in the \r
58djgpp port) complained about "multiple targets" in both the antlr and dlg \r
59makefiles. I got around the error by, in each makefile, commenting out the \r
60$(SRC) dependency, for example:\r
61\r
62 antlr: $(OBJ) #$(SRC)\r
63\r
64I don't know why this is happenning, since you haven't changed that part of \r
65the makefile at all, and I think this used to work ok...\r
66\r
67Here are the makefiles I built from within the MSVC 2.0 environment for antlr \r
68and dlg and Windows NT console executables. Please feel free to pass them \r
69on. Of course, as soon as 1.31 "goes gold", I will send you nice new \r
70binaries. I'm not going to bother to keep doing both Borland and djgpp for \r
71DOS however. Instead, I'll just keep the djgpp version up to date and also \r
72provide WinNT binaries.\r
73\r
74Dave\r
75===============================================================================\r
76\r
77 How to port PCCTS 1.10 (and 1.32 hopefully) to Visual C++\r
78\r
79 By\r
80\r
81 John Hall <jhall@ivy.wpi.edu>\r
82\r
83Here is how to compile an ANTLR grammar in Visual C++. These steps\r
84describe how to have your ANTLR grammar parse the input file the user\r
85selects when they choose File Open in your Windows application. (Even\r
86if you aren't using Visual C++, the steps should be portable enough to\r
87other compilers.)\r
88\r
89 * Make sure that ANTLR and DLG generate ANSI code (use the -ga\r
90 switch).\r
91\r
92 * Set the following compiler flags in Visual C++ (these are in the\r
93 Memory Model category of the compiler options in the Project\r
94 Options menu):\r
95\r
96 FLAG MEANING\r
97 ==== ==============================================================\r
98 /AL Large memory model (multiple data segments; data items must be\r
99 smaller than 64K).\r
100\r
101 /Gtn Allocates all items whose size is greater than or equal to n\r
102 in a new data segment. (I let n be 256: /Gt256.)\r
103\r
104 /Gx- All references to data items are done with far addressing in\r
105 case they are placed in a far segment.\r
106\r
107 * Add the following member variable to the attributes section of your\r
108 derived CDocument class (you will need to make sure you also\r
109 include stdio.h):\r
110\r
111 FILE *fp;\r
112\r
113 * Add the following method to your derived CDocument class:\r
114\r
115 BOOL CAppDoc::OnOpenDocument(const char* pszPathName)\r
116 {\r
117 // Call CDocument's OnOpenDocument to do housekeeping for us\r
118 // DON'T add anything to the loading section of Serialize\r
119 if (!CDocument::OnOpenDocument(pszPathName))\r
120 return FALSE;\r
121 \r
122 // Open input file\r
123 if ((fp = fopen(pszPathName, "r")) == NULL)\r
124 return FALSE;\r
125 \r
126 // Parse input file\r
127 ANTLR(start(), fp);\r
128 \r
129 // Close input file\r
130 fclose(fp);\r
131 return TRUE;\r
132 }\r
133\r
134 (Note: additional code may be necessary, depending on your parser.\r
135 For example, if your parser uses PCCTS's symbol table library, you\r
136 will need to insert calls to zzs_init and zzs_done.)\r
137\r
138 * Compile the generated C files as C++ files. (I renamed the files\r
139 to have a .CPP extension to fool Visual C++ into thinking they were\r
140 C++ files. One might also use the /Tp switch, but that switch\r
141 requires you separately include the filename.) [I used this step\r
142 as an easy out for all the external linking errors I was getting\r
143 that I couldn't fix by declaring things extern "C".]\r
144\r
145 * Make sure the __STDC__ portion of the generated files gets\r
146 compiled. (Either define __STDC__ yourself or else change all\r
147 occurrences of __STDC__ to __cplusplus in the generated files. You\r
148 can define __STDC__ in the Preprocessor category of the compiler\r
149 options.)\r
150\r
151 ================================================================\r
152 = Note 23-Sep-97: This is probably not necessary any more. =\r
153 = With 1.33MRxxx the use of __STDC__ was replaced with the =\r
154 = macro __USE_PROTOS to control the compilation of prototypes. =\r
155 ================================================================\r
156 \r
157That last step is important for Visual C++, but may not apply to other\r
158compilers. For C++ compilers, whether __STDC__ is defined is\r
159implementation dependent (ARM, page 379). Apparently, Visual C++ does\r
160not to define it; it also does not support "old style" C function\r
161definitions (which is okay, according to page 404 of the ARM). Those\r
162two things together caused problems when trying to port the code.\r
163When it saw this:\r
164\r
165#ifdef __STDC__\r
166void\r
167globals(AST **_root)\r
168#else\r
169globals(_root)\r
170AST **_root;\r
171#endif\r
172\r
173it skipped the __STDC__ section and tried to process the "old style"\r
174function definition, where it choked.\r
175\r
176When you finally get your parser to compile and link without error,\r
177you may get General Protection Fault errors at run time. The problem\r
178I had was that a NULL was passed to a variable argument function\r
179without an explicit cast. The function grabbed a pointer (32-bits)\r
180off the stack using va_arg, but the NULL was passed silently as the\r
181integer 0 (16 bits), making the resulting pointer was invalid. (This\r
182was in PCCTS's sample C parser.)\r
183\r
184There is one other thing I might suggest to help you avoid a run-time\r
185error. Make sure you redefine the default error reporting function,\r
186zzsyn. To do this, put "#define USER_ZZSYN" in your #header section\r
187and put your own zzsyn somewhere. You can then pop up a MessageBox or\r
188print the error to some output window.\r
189===============================================================================\r