如何在普通C中启动线程?(How do I start threads in plain C?)
我在C中使用了fork()来启动另一个进程。 如何开始新的线程?
I have used fork() in C to start another process. How do I start a new thread?
原文:https://stackoverflow.com/questions/56810
更新时间:2024-02-01 16:02
相关问答
更多-
输入'在哪里'解析错误(Parse Error on Input ‘where’)[2022-06-16]
在minXRec的第二个守卫中,你没有条件测试。 你需要改变 | minXRec [p1, p2, a*p1+p0] [q1, q2, a*q1+q0] newM newD newA n 最有可能的 | otherwise = minXRec [p1, p2, a*p1+p0] [q1, q2, a*q1+q0] newM newD newA n In the second guard of minXRec you don't have a conditional test. You will need ... -
你需要::在函数类型之前。 -- vv here v0 :: [Pos] -> Matrix -> [Pos] v0 [] _ = [] -- v v also parenthesis, not square brackets v0 (p:ps) m = if ((takeH m p) == 0) then v0 ps else p:v0 ps You need :: before the type of a function. ...
-
虽然从发布的代码中无法分辨出来,因为SO至少会在一段时间内将制表符转换为空格,但问题可能是您在putStrLn之前输入了一个字面制表符,而不是四个空格,就像您为其他两行do块,反之亦然。 do块中的所有语句do必须以完全相同的空格开始,而不是直观地排列起来。 如果您使用的是可以以特殊方式显示文字标签的文本编辑器,请将其设置为这样; 它会为你节省一些头痛。 Though it's impossible to tell from your posted code because SO converts tabs ...
-
您在where关键字之前使用制表符。 对于GHC,它看起来像这样: ␉ where␠(f:_)␠=␠firstname ␠␠␠␠␠␠␠␠␠(l:_)␠=␠lastname 因此,GHC认为where块中的第一行从第14列开始(第8行的选项卡计数为iirc),而第二行从第9列开始,这会导致错误。 您应该使用一个好的文本编辑器,将标签转换为4个空格。 You use a tab character before the where keyword. To GHC it looks like th ...
-
在Haskell源文件中,不应该使用let -just write来引入像f这样的顶级定义 f [] = [] f ('\n':',':a) = f ('\n' : a) f (a:b) = a : f b 此外,您需要确保定义中每个子句的左侧在同一列中排列,因为Haskell是缩进感知的。 因此,在这种情况下,每个子句中的f应该位于每行的最开头,如上所述。 请注意,ghci提示的行为更像是在do块中,因此let是有效的,这在两者之间移动时可能会引起混淆。 In Haskell source files, ...
-
解析输入错误'if'(Parse error on input 'if')[2022-08-19]
因为Haskell中的空白是很重要的。 您需要遵循缩进规则或使用显式大括号和分号(如在第二个代码块中)。 以下是修复第一个块的两种方法(还有其他方法): sgetLine = do x <- getChar if x == '\n' then do putChar x return [] else do ... -
我无法在本地重现错误,所以我的猜测是你使用制表符空格,如果你复制粘贴代码到编辑器,它应该“工作”。 在这种情况下,我们会收到另一个错误: GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( tmp.hs, interpreted ) tmp.hs:7:1: error: Equations for ‘apply’ have different numb ...
-
错误的输入解析错误?(Bad input parse error?)[2022-06-11]
在第133行中,左括号比右对齐多3个,每行的每一侧必须有相同数量的括号。 In line 133 you have got 3 more left brackets than right ones, you must have equal number of brackets for each side in each line. -
你在fix_error的定义中交换了=和if 。 定义的语法是: name args = body if表达式的语法是: if condition then true_branch else false_branch 你只需要结合这些: fix_error erro = if isDoesNotExistError erro ---- then do putStr "Exception: file doesn't exist" ... else io ...
-
你把parens放在错误的地方了吗? expression2 = (do operator lexer "|" a <- alternate as <- expression2 return $ a:as) <|> return [] Did you put the parens in the wrong place? expression2 = (do operator lexer "|" a <- alternate ...