@@ -125,7 +125,8 @@ namespace printer {
125125 types::PointerUsage usage,
126126 std::optional<std::string_view> value,
127127 std::optional<uint64_t > alignment,
128- bool complete) {
128+ bool complete,
129+ ExternType externType) {
129130 auto baseType = type.baseType ();
130131 std::string arrayName{ name.data (), name.length () };
131132
@@ -135,6 +136,18 @@ namespace printer {
135136 }
136137
137138 ss << LINE_INDENT ();
139+ switch (externType) {
140+ case ExternType::C :
141+ if (getLanguage () == utbot::Language::CXX) {
142+ ss << " extern \" C\" " ;
143+ break ;
144+ }
145+ case ExternType::SAME_LANGUAGE :
146+ ss << " extern " ;
147+ break ;
148+ case ExternType::NONE :
149+ break ;
150+ }
138151 printAlignmentIfExists (alignment);
139152 ss << baseType << " " << arrayName;
140153 std::vector<size_t > sizes = type.arraysSizes (usage);
@@ -539,15 +552,16 @@ namespace printer {
539552 }
540553 }
541554
542- void printer::Printer::writeExternForSymbolicStubs (const Tests::MethodDescription& testMethod) {
543- std::unordered_map<std::string, std::string > symbolicNamesToTypesMap;
544- for (const auto & testCase: testMethod.testCases ) {
555+ void printer::Printer::writeExternForSymbolicStubs (const Tests::MethodDescription & testMethod) {
556+ std::unordered_map<std::string, types::Type > symbolicNamesToTypesMap;
557+ for (const auto & testCase: testMethod.testCases ) {
545558 for (size_t i = 0 ; i < testCase.stubValues .size (); i++) {
546- symbolicNamesToTypesMap[testCase.stubValues [i].name ] = testCase.stubValuesTypes [i].type . usedType () ;
559+ symbolicNamesToTypesMap[testCase.stubValues [i].name ] = testCase.stubValuesTypes [i].type ;
547560 }
548561 }
549- for (const auto & [name, type]: symbolicNamesToTypesMap) {
550- strDeclareVar (" extern \" C\" " + type, name);
562+ for (const auto &[name, type]: symbolicNamesToTypesMap) {
563+ strDeclareArrayVar (type, name, types::PointerUsage::PARAMETER, std::nullopt , std::nullopt , true ,
564+ ExternType::C);
551565 }
552566 }
553567
0 commit comments