(self, env: 'Environment')
Check if the compiler prefixes an underscore to global C symbols
Check if the compiler prefixes an underscore to global C symbols
Check if the compiler prefixes an underscore to global C symbols
def symbols_have_underscore_prefix(self, env: 'Environment') -> bool:
        '''
        Check if the compiler prefixes an underscore to global C symbols
        '''
        symbol_name = b'meson_uscore_prefix'
        code = '''#ifdef __cplusplus
        extern "C" {
        #endif
        void ''' + symbol_name.decode() + ''' (void) {}
        #ifdef __cplusplus
        }
        #endif
        '''
        args = self.get_compiler_check_args(CompileCheckMode.COMPILE)
        n = 'symbols_have_underscore_prefix'
        with self._build_wrapper(code, env, extra_args=args, mode='compile', want_output=True, temp_dir=env.scratch_dir) as p:
            if p.returncode != 0:
                raise RuntimeError(f'BUG: Unable to compile {n!r} check: {p.stdout}')
            if not os.path.isfile(p.output_name):
                raise RuntimeError(f'BUG: Can\'t find compiled test code for {n!r} check')
            with open(p.output_name, 'rb') as o:
                for line in o:
                    # Check if the underscore form of the symbol is somewhere
                    # in the output file.
                    if b'_' + symbol_name in line:
                        mlog.debug("Symbols have underscore prefix: YES")
                        return True
                    # Else, check if the non-underscored form is present
                    elif symbol_name in line:
                        mlog.debug("Symbols have underscore prefix: NO")
                        return False
        raise RuntimeError(f'BUG: {n!r} check failed unexpectedly')
def symbols_have_underscore_prefix ( self , env : 'Environment' ) -> bool : symbol_name = b'meson_uscore_prefix' code = '''#ifdef __cplusplus
        extern "C" {
        #endif
        void ''' + symbol_name . decode ( ) + ''' (void) {}
        #ifdef __cplusplus
        }
        #endif
        ''' args = self . get_compiler_check_args ( CompileCheckMode . COMPILE ) n = 'symbols_have_underscore_prefix' with self . _build_wrapper ( code , env , extra_args = args , mode = 'compile' , want_output = True , temp_dir = env . scratch_dir ) as p : if p . returncode != 0 : raise RuntimeError ( f'BUG: Unable to compile {n!r} check: {p.stdout}' ) if not os . path . isfile ( p . output_name ) : raise RuntimeError ( f'BUG: Can\'t find compiled test code for {n!r} check' ) with open ( p . output_name , 'rb' ) as o : for line in o : # Check if the underscore form of the symbol is somewhere # in the output file. if b'_' + symbol_name in line : mlog . debug ( "Symbols have underscore prefix: YES" ) return True # Else, check if the non-underscored form is present elif symbol_name in line : mlog . debug ( "Symbols have underscore prefix: NO" ) return False raise RuntimeError ( f'BUG: {n!r} check failed unexpectedly' )