On Friday, July 28, 2023 at 11:31:02 AM UTC-4, Paul Edwards wrote:
Try combining both suggestions - ie put main as the first
file, and do a return 0 after the first printf.
I did. It didn'yt work. :(
Also send both the main.c code and the compile command
you are using so that I can see again.
Also send the working hello world - both code and compile command.
The problem code:
---------------------------------- /***********************************************************************
*
* Individual module for the ANSI compiler.
*
* The template for this file was created by TempC Module Creator by
* Joseph Rose. This template can be used in your programs, provided
* you mention TempC in your software's documentation. If this source
* code is distributed, this copyright must be included in the file.
*
***********************************************************************/
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "in.h"
#include "buffer.h"
struct __indata {
enum {
sysCBM,
sysAtari,
sysApple2
} sys;
char toktype[16];
char littype[16];
struct {
unsigned docurchar;
char curcharname[32];
unsigned docharptr;
char curptrname[32];
} dozp;
char outname[256];
} indata;
unsigned loadfile (char* name);
int main (int argc, char** argv)
{
char c, c2;
struct string_buffer * atstring;
//Enable the following line and declare
//char programname[128]; if the executable path is
//needed:
//strcpy (programname, argv[0]);
//Analyze the command line:
puts ("Ready to start program!"); getchar();
while (--argc) {
//Advance to next arg.
argv++;
printf ("Para %s\n", *argv); getchar();
//Is it a switch?
if (argv[0][0]=='-') {
//Process switch:
putchar ((argv[0][1])); puts(""); getchar();
switch (argv[0][1]) {
case 't':
//puts ("t switch processed.");
--argc; argv++;
if (!strcmp(*argv, "cbm")) indata.sys=sysCBM;
else if (!strcmp(*argv, "apple2")) indata.sys=sysApple2;
else if (!strcmp(*argv, "atari")) indata.sys=sysAtari;
else {
puts ("Error parsing cmdline: unrecognized target system.");
return 1;
}
break;
case 'o':
--argc; argv++;
strcpy (indata.outname, *argv);
break;
case 'c':
// switch (argv[0][2]) {
// case 't':
// case 'l':
// }
c=argv[0][2];
--argc; argv++;
if (c=='t') strcpy (indata.toktype,*argv);
else if (c=='l') strcpy (indata.littype,*argv);
else {
puts ("Error parsing cmdline: unrecognized compression type.");
return 1;
}
break;
case '?': //Print help.
puts ("Help."); return 0;
default: //Trap bad switch.
printf ("Bad switch: %c.", argv[0][1]); return 1;
}
} else { //Handle filename:
//printf ("File: %s\n", argv[0]);
//--argc; argv++;
puts (*argv); getchar();
if (loadfile(*argv)) {
printf ("Error in file \"%s\"\n", *argv);
return 2;
}
}
}
// if ()
puts ("Ready to print strings!"); getchar();
if (!strings) {
puts ("No input strings!"); return 2;
}
atstring=strings;
do {
puts (atstring->name);
puts ("----------------");
puts (atstring->in);
printf (">>> len=%d\n", atstring->inlen);
puts ("=================");
atstring=atstring->next;
} while (atstring);
puts ("---end!");
getchar();
return 0;
}
----------------------------------
The compile command:
------------------------------
c:\dm\bin\dmc buffer.c in.c main.c -o -mn -4 -optok_comp.exe -------------------------------------
The Hello, world example:
-------------------------------------- /***********************************************************************
*
* Individual module for the ANSI compiler.
*
* The template for this file was created by TempC Module Creator by
* Joseph Rose. This template can be used in your programs, provided
* you mention TempC in your software's documentation. If this source
* code is distributed, this copyright must be included in the file.
*
***********************************************************************/
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (int argc, char** argv)
{
//Enable the following line and declare
//char programname[128]; if the executable path is
//needed:
//strcpy (programname, argv[0]);
//Analyze the command line:
puts ("Hello, world!"); getchar();
return 0;
}
------------------------------
Its compile command:
---------------------------------
c:\dm\bin\dmc main.c -o -mn -4 -otet.exe
---------------------------------
BTW, it seems to work on a Win7/64 laptop. I'm going to try to port this code to Open Watcom soon....
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)