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