Hi
I am using Matlab 2021a
I am getting an error while generating S-function from my simulink model.
I am using Microsoft Visual C++ 2019 (C) for C language compilation.
I created healthy S-functions and their .mex files with this compiler before, but in this Simulink model it gives an error.
While it is creating simModel_sf.c file, in some part it is giving an syntax error in Microsoft Visual Studio 'cstring' file and stops creating .c file and S-function and mex file.
The error message is :
Top model targets built:
Model Action Rebuild Reason
================================================
simModel Failed ForceTopModelBuild was enabled.
0 of 1 models built (0 models already up to date)
Build duration: 0h 8m 34.436s
simModel_sf.c
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstring(21): error C2061: syntax error: identifier 'std'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstring(21): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstring(21): error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstring(50): error C2059: syntax error: '}'
C:\Users\Administrator\Desktop\simModelFile\simModel_sfcn_rtw\simModel_sf.c(102309): fatal error C1004: unexpected end-of-file found
and I am copying the cstring file content . The current 'cstring' file content and error creating lines are starting with _STD_BEGIN in 21th line and _STD_END in 50th line.
// cstring standard header (core)
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#pragma once
#ifndef _CSTRING_
#define _CSTRING_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <string.h>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
#pragma warning(push)
#pragma warning(disable : 4995) // name was marked as #pragma deprecated
using _CSTD size_t;
using _CSTD memchr;
using _CSTD memcmp;
using _CSTD memcpy;
using _CSTD memmove;
using _CSTD memset;
using _CSTD strcat;
using _CSTD strchr;
using _CSTD strcmp;
using _CSTD strcoll;
using _CSTD strcpy;
using _CSTD strcspn;
using _CSTD strerror;
using _CSTD strlen;
using _CSTD strncat;
using _CSTD strncmp;
using _CSTD strncpy;
using _CSTD strpbrk;
using _CSTD strrchr;
using _CSTD strspn;
using _CSTD strstr;
using _CSTD strtok;
using _CSTD strxfrm;
#pragma warning(pop)
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _CSTRING_
What could be the problem here? Is there maybe a header conflicting from my current path includes with Visual Studio headers?
I tried
mex -setup c
mex -setup cpp but both didn't work. Any help would be much appreciated.
Thank you