|
|
Example:
public class prog { public static void main(String[] args) { int a, b; a = 2; b = prog2.f( a ); // f( ) is defined in ANOTHER Java program file !!! } } |
When you compile the program prog.java:
javac prog.java |
The Java compiler will automatically search for missing information in the file prog2.java
Demo:
cd /home/cs255000/demo/c/Compiler javac prog.java |
|
Example:
prog.c: int main(int argc, char *argv[]) { int a, b; a = 2; b = f( a ); // f( ) is defined in ANOTHER C program file !!! } } |
When you compile the program prog.c:
gcc prog.c |
The Java compiler will report an error:
cs255 (1732)> gcc prog.c /tmp/ccSbeAWZ.o: In function `main': prog.c:(.text+0x21): undefined reference to `f' (Because the C compiler cannot find f( ) in the file !!!) |
Demo:
cd /home/cs255000/demo/c/Compiler gcc prog.c |