mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-08-06 05:32:35 +08:00
Fix link errors with MinGW.
MinGW supports a limited form of weak symbols, with the restriction that weak/default implementations need to be defined in the same translation unit they are called from. Strong/overriding symbols may of course be specified in a different translation unit.
This commit is contained in:
@ -158,6 +158,7 @@ class UnityTestRunnerGenerator
|
||||
create_runtest(output, mocks)
|
||||
output.puts("\n/*=======Automagically Detected Files To Include=====*/")
|
||||
output.puts("#include \"#{@options[:framework]}.h\"")
|
||||
output.puts("#include \"#{@options[:framework]}_setup.h\"")
|
||||
output.puts('#include "cmock.h"') unless mocks.empty?
|
||||
output.puts('#include <setjmp.h>')
|
||||
output.puts('#include <stdio.h>')
|
||||
|
18
src/unity.c
18
src/unity.c
@ -5,6 +5,7 @@
|
||||
============================================================================ */
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_setup.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/* If omitted from header, declare overrideable prototypes here so they're ready for use */
|
||||
@ -1310,23 +1311,6 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
|
||||
UNITY_IGNORE_AND_BAIL;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
#if defined(UNITY_WEAK_ATTRIBUTE)
|
||||
UNITY_WEAK_ATTRIBUTE void setUp(void) { }
|
||||
UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
|
||||
UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { }
|
||||
UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; }
|
||||
#elif defined(UNITY_WEAK_PRAGMA)
|
||||
#pragma weak setUp
|
||||
void setUp(void) { }
|
||||
#pragma weak tearDown
|
||||
void tearDown(void) { }
|
||||
#pragma weak suiteSetUp
|
||||
void suiteSetUp(void) { }
|
||||
#pragma weak suiteTearDown
|
||||
int suiteTearDown(int num_failures) { return num_failures; }
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
|
||||
{
|
||||
|
33
src/unity_setup.h
Normal file
33
src/unity_setup.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* ==========================================
|
||||
Unity Project - A Test Framework for C
|
||||
Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
[Released under MIT License. Please refer to license.txt for details]
|
||||
========================================== */
|
||||
|
||||
#ifndef UNITY_SETUP_H
|
||||
#define UNITY_SETUP_H
|
||||
|
||||
#include "unity_internals.h"
|
||||
|
||||
/* On some platforms (MinGW for example), weak function implementations
|
||||
* need to be in the same translation unit they are called from. This
|
||||
* header can be included to provide implementations of setUp(), tearDown(),
|
||||
* suiteSetUp(), and suiteTearDown(). */
|
||||
|
||||
#if defined(UNITY_WEAK_ATTRIBUTE)
|
||||
UNITY_WEAK_ATTRIBUTE void setUp(void) { }
|
||||
UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
|
||||
UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { }
|
||||
UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; }
|
||||
#elif defined(UNITY_WEAK_PRAGMA)
|
||||
#pragma weak setUp
|
||||
void setUp(void) { }
|
||||
#pragma weak tearDown
|
||||
void tearDown(void) { }
|
||||
#pragma weak suiteSetUp
|
||||
void suiteSetUp(void) { }
|
||||
#pragma weak suiteTearDown
|
||||
int suiteTearDown(int num_failures) { return num_failures; }
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user