我刚刚开始使用Code Runner,由于某种原因它不会编译我的C程序。
错误如下:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
module.exports = functions.https.onRequest((req, res) => {
const conversationID = req.query.conversationID;
const currentUserID = req.query.currentUserID;
console.log("conversationID", conversationID, "currentUserID", currentUserID);
const conversationUsersRef = admin.database().ref("chat").child("conversationUsers").child(conversationID);
conversationUsersRef.once("value").then(conversationUsersRefSnap => {
var index = 0;
var totalIndex = 0;
var conversationUsersImagesArray = [];
conversationUsersRefSnap.forEach(function(conversationUserSnap) {
console.log("conversationUserSnap", conversationUserSnap.val());
console.log("$index", index);
const dict = conversationUserSnap.val();
const conversationUserID = dict["userID"];
if (conversationUserID != currentUserID) {
index += 1;
const userSenderImageQuery = admin.database().ref('userImages').child(conversationUserID).child('userProfileImages').orderByChild('timeStamp').limitToLast(1);
userSenderImageQuery.once('value', function (snapshot, error) {
var imagePath = '';
if (error) {
index -= 1;
if (conversationUsersImagesArray.length == index) {
console.log("total", conversationUsersImagesArray);
res.status(200).send(conversationUsersImagesArray);
};
} else {
if (snapshot.val()) {
const value = snapshot.val();
const key = Object.keys(value)[0];
const requestJSON = value[key];
console.log('senderImageQuery requestJSON', requestJSON);
const userImagePath = requestJSON['path'];
imagePath = userImagePath;
const compressPath = requestJSON["compressPath"];
if (compressPath) {
imagePath = compressPath;
};
conversationUsersImagesArray.push({"userID" : conversationUserID, "imagePath" : imagePath, "conversationID" : conversationID});
console.log("conversationUsersImages", conversationUsersImagesArray.length, "index", index);
if (conversationUsersImagesArray.length == index) {
console.log("total", conversationUsersImagesArray);
res.status(200).send(conversationUsersImagesArray);
};
} else {
index -= 1;
if (conversationUsersImagesArray.length == index) {
console.log("total", conversationUsersImagesArray);
res.status(200).send(conversationUsersImagesArray);
};
};
};
});
};
});
});
});
的main.c
Undefined symbols for architecture x86_64:
"_rush", referenced from:
_main in main-f9aa06.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ftputchar.c
#include <stdio.h>
int ft_putchar(char c);
void rush(int x, int y);
int main(void){
int x, y;
scanf("%i", &x);
scanf("%i", &y);
rush(x, y);
return (0);
}
rush.c
#include <unistd.h>
int ft_putchar(char c){
write(1, &c, 1);
return (0);
}
Code Runner v2.3
然而,当我使用XCode编译并运行代码时,它完全正常。
此外,如果我将所有内容放入 main.c 文件中,则代码会运行并完美编译。