0

I'm using Watcom C32 Optimizing Compiler Version 11.0.

I developed a sample program test.exe. This will create a file with long file name (ex: "sample file for testing.txt") and write some dummy content in it.

#include <stdio.h>

int main(void)
{
    FILE *fptr = fopen("e:\\sample file for testing.txt", "w");
    
    fprintf(fptr,"test");
    fclose(fptr);

    return 0;
}

When I compile and execute the program on a FreeDOS environment with DOSLFN loaded, I see that the sample program test.exe is creating a file with short file name ("sample f.txt") instead of long file name ("sample file for testing.txt") .

So that makes me to think that Watcom is not supporting the Long file name(LFN).

Any suggestion to make the LFN to work in Watcom? I looked at the compiler option and didn't see any. Is there any special macro needs to be enabled to make it work?

Anand
  • 374
  • 2
  • 11
  • How standardized is LFN? If you're using a DOS compiler, it may not understand that, and adding support might be non-trivial. Could you write a batch file to fix the name after compiling? – tadman Aug 04 '20 at 21:53
  • I improved the question. The test.exe program is always creating the output file with short names instead of long names. – Anand Aug 04 '20 at 22:10
  • @tadman The FreeDOS won't support LFN by itself. When I load the DOSLFN, then it will support the LFN. When I compile the above program using GCC and execute, I'm getting the file generated with long file name as expected. I'm facing issue only when I compile the program using Watcom compiler. – Anand Aug 04 '20 at 22:14
  • Did you try to follow your program on the machine code level? Granted, it might get tedious to step through Watcom's code, but you could finally see if it cuts the file name. -- Did you search for special functions to use for LFN? Perhaps GCC checks for them and uses them under the hood. – the busybee Aug 05 '20 at 17:38
  • It appears like the Watcom 11.0 compiler itself is not supporting the LFN. I tried Open Watcom 2.0 with LFN macro enabled at the beginning of the program and it works fine. We still need to load DOSLFN driver in FreeDOS for the LFN to work with Open Watcom 2.0. Please note loading DOSLFN slow down some functions in FreeDOS. – Anand Aug 11 '20 at 22:11

0 Answers0