function stackDriver = generalStackDriver(lBitPerPointer)
% Return a generic stack driver that can be used on different platforms

%   Copyright 2021 The MathWorks, Inc.

    if ~any(lBitPerPointer == [8 16 32 64])
        DAStudio.error('CoderProfile:ExecutionStack:WrongBitsForPtr', lBitPerPointer);
    end

    driverDir = fullfile(matlabroot, 'toolbox', 'coder', 'profile', 'src');
    stackDriver = coder.profile.StackDriver();
    stackDriver.PtrDataType = sprintf('uint%d', lBitPerPointer);
    stackDriver.HeaderFile = 'general_stack.h';
    stackDriver.IncludePaths = {driverDir};
    stackDriver.SourceFile = fullfile(driverDir, 'general_stack.c');
    stackDriver.DriverFunction = 'general_strckptr';
    stackDriver.Defines = {sprintf('_STACK_PTR_TYPE=%s', stackDriver.getCodeType())};
end
