Discussion:
How do I compile a C program?
(too old to reply)
Johann 'Myrkraverk' Oskarsson
2019-10-25 04:28:57 UTC
Permalink
Dear c.s.i.a.misc,

I am using the public access system, pub400.com.

How do I go about compiling a C program. I believe I've entered it
correctly in myrkravrk1/qcsrc, member named hello. See below.

Then I believe I should be able to compile with

crtcmod module(myrkravrk1/hello) srcfile(myrkravrk1/qcsrc)

but all I get is the message

Module HELLO is not created because statement errors occurred.

and I don't know what that means. Is this an error in my command line,
or a compilation error?

I am very new to System I, or AS/400. And I'm just starting to get the
various concepts of libraries, files, and members. A screenshot follows
with truncated columns.

Columns . . . : 1 80 Edit MYRKRAVRK1/QCSRC
SEU==> HELLO
FMT ** ...+... 1 <snip> ...+... 8

*************** Beginning of data ********
001.00 #include <stdio.h> 191025

002.00 void main( void ) 191025

003.00 { 191025

004.00 printf( "Hello, world\n" ); 191025

005.00 } 191025

****************** End of data **********

Am I correctly referring the source file on my command line?
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Jonathan Bailey
2019-10-25 08:11:30 UTC
Permalink
Post by Johann 'Myrkraverk' Oskarsson
Dear c.s.i.a.misc,
I am using the public access system, pub400.com.
How do I go about compiling a C program. I believe I've entered it
correctly in myrkravrk1/qcsrc, member named hello. See below.
Then I believe I should be able to compile with
crtcmod module(myrkravrk1/hello) srcfile(myrkravrk1/qcsrc)
but all I get is the message
Module HELLO is not created because statement errors occurred.
and I don't know what that means. Is this an error in my command line,
or a compilation error?
I am very new to System I, or AS/400. And I'm just starting to get the
various concepts of libraries, files, and members. A screenshot follows
with truncated columns.
Columns . . . : 1 80 Edit MYRKRAVRK1/QCSRC
SEU==> HELLO
FMT ** ...+... 1 <snip> ...+... 8
*************** Beginning of data ********
001.00 #include <stdio.h> 191025
002.00 void main( void ) 191025
003.00 { 191025
004.00 printf( "Hello, world\n" ); 191025
005.00 } 191025
****************** End of data **********
Am I correctly referring the source file on my command line?
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
It works OK for me just replacing myrkraverk with baileyj.
You can do a few things:
type dspjoblog at a command line then F10 and page up. This might show some errors
add OUTPUT(*print) to the crtcmod command (hint press F4 before enter then F9 and you can explore a whole range of extras)
After that type wrksplf at a command line. then select the spoolfile with option 5 and that should show the errors. You might find the {} are mangled by the CCSID settings. That might require changing your job or re-creating qcsrc.
Last, you should probably use crtbndc which will generate a program which you can call with
call myrkravrk1/hello
modules cannot be called, only merged with other modules into programs or service programs. Or copied/deleted/saved to tape etc.

HTH
Jonathan
Johann 'Myrkraverk' Oskarsson
2019-10-25 08:32:21 UTC
Permalink
Post by Jonathan Bailey
You might find the {} are mangled by the CCSID settings. That might require changing your job or re-creating qcsrc.
Indeed that is the problem.

3 > crtcmod module(myrkravrk1/hello) srcfile(myrkravrk1/qcsrc)
MYRKRAVRK1/QCSRC(HELLO), 3.1: CZM0191(20) The character {
is not a valid C source character.
MYRKRAVRK1/QCSRC(HELLO), 5.1: CZM0191(20) The character }
is not a valid C source character.
MYRKRAVRK1/QCSRC(HELLO), 4.3: CZM0046(30) Syntax error.
Module HELLO is not created because statement errors occurred.
The compilation failed.

How would I go about "changing my job" or "recreating qcsrc?"
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Johann 'Myrkraverk' Oskarsson
2019-10-25 08:51:06 UTC
Permalink
Post by Johann 'Myrkraverk' Oskarsson
How would I go about "changing my job" or "recreating qcsrc?"
A quick google led me to this:


https://www.code400.com/forum/forum/iseries-programming-languages/any-thing-goes/12139-the-character-%7D-is-not-a-valid-c-source-character

Which suggests it's a problem with my terminal encoding. I am using
Mocha TN5250 for Windows. My AS/400 code page is set to US(037) and
locally I have checked "Use Windows OS default encoding." Are these
settings relevant to the { } characters being wrong?
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Johann 'Myrkraverk' Oskarsson
2019-10-25 08:56:29 UTC
Permalink
Which suggests it's a problem with my terminal encoding.  I am using
Mocha TN5250 for Windows.  My AS/400 code page is set to US(037) and
locally I have checked "Use Windows OS default encoding."  Are these
settings relevant to the { } characters being wrong?
Indeed it is, after setting the AS/400 code page to Austria/Germany
(273) and editing my source file, I have successfully compiled the module.
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Johann 'Myrkraverk' Oskarsson
2019-10-25 09:03:51 UTC
Permalink
Post by Jonathan Bailey
Last, you should probably use crtbndc which will generate a program which you can call with
call myrkravrk1/hello
Indeed, I've done this now; thank you.
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
Jonathan Bailey
2019-10-25 10:15:15 UTC
Permalink
Post by Johann 'Myrkraverk' Oskarsson
Post by Jonathan Bailey
Last, you should probably use crtbndc which will generate a program which you can call with
call myrkravrk1/hello
Indeed, I've done this now; thank you.
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
Great
Well done
Next stop RPG :)

Jonathan.

Loading...