PellesC batch file

Started by jbk, October 27, 2025, 08:06:34 PM

Previous topic - Next topic

jbk


MrBcx

#4
Short answer - no.

When BCX is instructed to emit a c++ file, either by $CPP directive, or command line switch, or
by code detection, the first lines that BCX emits are:


// *************************************************
//      Made with BCX BASIC To C/C++ Translator
//            Version 8.3.0 (10/23/2025)
// *************************************************
//    Translated for compiling with a C++ Compiler
// *************************************************
 
#ifndef __cplusplus
  #error A C++ compiler is required
#endif



If you were hoping to do something like this in the BASIC file, it won't work.

CONST BUILD_CPP

$IFDEF BUILD_CPP
    $CPP
$ENDIF


Simply using $CPP ( or not ) in your code accomplishes the same thing as the above conditional.


Now, more generally, when Pelles is processing code, it defines __POCC__ which you can take advantage
of using BCX's conditional directives but, knowing that, won't get you there if BCX created the cpp file.


#ifndef __cplusplus
  #error A C++ compiler is required
#endif

jbk

#3
thank you MrBcx  :)
is there a way to use the preprocessor to conditionally not use $CPP if the compiler is PellesC?

MrBcx

#2
Quote from: jbk on October 27, 2025, 08:06:34 PMPellesC does not seem to like cpp extensions so I altered the bat files like the following
IF EXIST "%~dpn1.c" DEL "%~dpn1.c"
IF EXIST "%~dpn1.cpp" DEL "%~dpn1.cpp"

%BCX%\Bc.exe  %1>bcxout.txt

IF EXIST "%~dpn1.cpp" (
    ren "%~dpn1.cpp" "%~dpn1.c"
)
but it doesn't rename the file, why?

JB - you cannot simply rename a *.cpp file to *.c. 

Pelles C is not a c++ compiler, so passing it a *.cpp file, regardless of file extension, is asking for trouble. 
If you're trying to compile a BCX app that has the $CPP  directive in it, that directive must be commented
out or removed, if you're trying to build with a plain C compiler.


jbk

PellesC does not seem to like cpp extensions so I altered the bat files like the following
IF EXIST "%~dpn1.c" DEL "%~dpn1.c"
IF EXIST "%~dpn1.cpp" DEL "%~dpn1.cpp"

%BCX%\Bc.exe   %1>bcxout.txt

IF EXIST "%~dpn1.cpp" (
ren "%~dpn1.cpp" "%~dpn1.c"
)
but it doesn't rename the file, why?