提交 a7e8797e 编写于 作者: J John Lindgren

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.
上级 1381a1a4
......@@ -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>')
......
......@@ -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)
{
......
/* ==========================================
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册