C in JBC Program
- ironmaiden
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 83
- Thank you received: 0
19 years 5 months ago #2022
by ironmaiden
C in JBC Program was created by ironmaiden
In jBASE 4.0 do any one know how to use a C method inside a JBC program. please advice
_________________
NJOY LIFE TO THE FULLEST
_________________
NJOY LIFE TO THE FULLEST
Please Log in or Create an account to join the conversation.
- malai
-
- Offline
- Platinum Member
-
Less
More
- Posts: 509
- Thank you received: 11
19 years 5 months ago #2023
by malai
Replied by malai on topic Its Simple
Hi Iron,
Its very simple. Since jbc itself is a C compiler u can use jbc to compile your C program and also the JBC program.
Lets see an example.
C Program
This C program is used to add two numbers. The method ADD_TWO_NUMBER is used for this purpose. It gets 2 integer arguments and returns 1 integer argument.
File . , Record 'my.c'
Command->
0001 #include <jsystem.h>
0002
0003 int ADD_TWO_NUMBER (int num1, int num2)
0004 {
0005 int result = num1 + num2;
0006 return result;
0007 }
JBC program
This jbc program make use of the above C program to add two numbers. DEFC is the command to link a JBC program with a C program.
File . , Record 'myb.b'
Command->
0001 PROGRAM myb.b
0002 DEFC INT ADD_TWO_NUMBER(INT,INT)
0003 VA1 = 10;
0004 VA2 = 20;
0005 VA3 = ADD_TWO_NUMBER(VA1,VA2);
0006 PRINT VA3
0007 STOP
Compilation
Now compile both the programs using jbc
jbc -J04 myb.b my.c -o myapp
The optional parameter -JO4 informs the compiler that full optimization is to be carried out on the jBC and C code
Execution
Now execute the basic program.
myapp
30
Thats All
_________________
M A L A I
Its very simple. Since jbc itself is a C compiler u can use jbc to compile your C program and also the JBC program.
Lets see an example.
C Program
This C program is used to add two numbers. The method ADD_TWO_NUMBER is used for this purpose. It gets 2 integer arguments and returns 1 integer argument.
File . , Record 'my.c'
Command->
0001 #include <jsystem.h>
0002
0003 int ADD_TWO_NUMBER (int num1, int num2)
0004 {
0005 int result = num1 + num2;
0006 return result;
0007 }
JBC program
This jbc program make use of the above C program to add two numbers. DEFC is the command to link a JBC program with a C program.
File . , Record 'myb.b'
Command->
0001 PROGRAM myb.b
0002 DEFC INT ADD_TWO_NUMBER(INT,INT)
0003 VA1 = 10;
0004 VA2 = 20;
0005 VA3 = ADD_TWO_NUMBER(VA1,VA2);
0006 PRINT VA3
0007 STOP
Compilation
Now compile both the programs using jbc
jbc -J04 myb.b my.c -o myapp
The optional parameter -JO4 informs the compiler that full optimization is to be carried out on the jBC and C code
Execution
Now execute the basic program.
myapp
30
Thats All
_________________
M A L A I
Please Log in or Create an account to join the conversation.
- ironmaiden
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 83
- Thank you received: 0
19 years 3 months ago #2024
by ironmaiden
Replied by ironmaiden on topic C in JBC Program
Has anyone tried calling a C function in jBASE 4.1 If so can u please let me know with some examples
Thanks...
_________________
NJOY LIFE TO THE FULLEST
Thanks...
_________________
NJOY LIFE TO THE FULLEST
Please Log in or Create an account to join the conversation.
- malai
-
- Offline
- Platinum Member
-
Less
More
- Posts: 509
- Thank you received: 11
19 years 3 months ago #2025
by malai
Replied by malai on topic C in JBC Program
jbc
In the above example in jBASE4.0, the command compiles the jBC code , the C code, and produce the UNIX executable myapp.
i.e) Compilation of both the programs are done in a single shot.
jcompile
Instead of doing in a single shot. We can follow the steps given below.
1. Compile the C program and create a library file (.so and .so.el)
2. Compile the JBC program by linking the above library, and create the object file.
3. Execute the JBC object file.
I think this would be hepfull to you. Creating library files are already covered in this forum, make use of that.
If you still face any program, let me know about that.
_________________
M A L A I
In the above example in jBASE4.0, the command compiles the jBC code , the C code, and produce the UNIX executable myapp.
i.e) Compilation of both the programs are done in a single shot.
jcompile
Instead of doing in a single shot. We can follow the steps given below.
1. Compile the C program and create a library file (.so and .so.el)
2. Compile the JBC program by linking the above library, and create the object file.
3. Execute the JBC object file.
I think this would be hepfull to you. Creating library files are already covered in this forum, make use of that.
If you still face any program, let me know about that.
_________________
M A L A I
The following user(s) said Thank You: Rytvin
Please Log in or Create an account to join the conversation.
- Rytvin
- Offline
- New Member
-
Less
More
- Posts: 1
- Thank you received: 0
13 years 4 months ago #10498
by Rytvin
Replied by Rytvin on topic Re: Its Simple
Hi.
I have the same problem. But i have no JBC compile in present.
Is there ani other way ?
I try to use jcompile, but recieved problem with no - JSYSTEM.H .
Help, plz
I have the same problem. But i have no JBC compile in present.
Is there ani other way ?
I try to use jcompile, but recieved problem with no - JSYSTEM.H .
Help, plz
Please Log in or Create an account to join the conversation.
Time to create page: 0.030 seconds