2014-04-10 9 views
6

http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspxसंकलन सी कोड complex.h पुस्तकालय के साथ

C99 समर्थन विजुअल स्टूडियो 2013 जोड़ा है, लेकिन मैं नहीं कर सकते मेरी 'सी' कोड में complex.h का उपयोग करें।

#include <stdio.h> 
#include <complex.h> 
int main(void) 
{ 
    double complex dc1 = 3 + 2 * I; 
    double complex dc2 = 4 + 5 * I; 
    double complex result; 

    result = dc1 + dc2; 
    printf(" ??? \n", result); 

    return 0; 
} 

मुझे वाक्यविन्यास त्रुटियां मिलती हैं।

संपादित करें: अनुपलब्ध भाग के लिए खेद है।

error C2146: syntax error : missing ';' before identifier 'dc1' 
error C2065: 'dc1' : undeclared identifier 
error C2088: '*' : illegal for struct 
error C2086: 'double complex' : redefinition 
error C2146: syntax error : missing ';' before identifier 'dc2' 
error C2065: 'dc2' : undeclared identifier 
error C2088: '*' : illegal for struct 
error C2086: 'double complex' : redefinition 
error C2146: syntax error : missing ';' before identifier 'result' 
error C2065: 'result' : undeclared identifier 
error C2065: 'result' : undeclared identifier 
error C2065: 'dc1' : undeclared identifier 
error C2065: 'dc2' : undeclared identifier 
error C2065: 'result' : undeclared identifier   
IntelliSense: expected a ';' 
IntelliSense: expected a ';' 
IntelliSense: expected a ';' 
IntelliSense: identifier "result" is undefined 
IntelliSense: identifier "dc1" is undefined 
IntelliSense: identifier "dc2" is undefined 
+0

और जहां आप इन sysntax त्रुटियों मिलता है? –

+6

जब आप त्रुटियों के बारे में कोई प्रश्न पोस्ट करते हैं, तो प्रश्न में वास्तविक त्रुटियों (* पूर्ण * और * unedited *) को शामिल करना बहुत उपयोगी होता है। त्रुटियों को शामिल करने के लिए कृपया अपना प्रश्न संपादित करें। –

+3

ऐसा लगता है कि 'जटिल' के लिए समर्थन पूर्ण नहीं है क्योंकि ब्लॉग-पोस्ट हमें बताता है। –

उत्तर

7

मामले किसी में एक साल बाद खोज कर रहा है,

_Dcomplex dc1 = {3.0, 2.0};

चर घोषणा के लिए

प्रयास करें।

वीएस2013 के "complex.h" हेडर के अंदर देखने से, ऐसा लगता है कि माइक्रोसॉफ्ट ने सी जटिल संख्याओं के लिए अपने स्वयं के कार्यान्वयन पर फैसला किया है। आप() फ़ंक्शन का उपयोग कर असली() और imag, अपने खुद के अंकगणितीय ऑपरेटर्स को लागू करना होगा यानी .:

double real_part = real(dc1) + real(dc2); 
double imag_part = imag(dc1) + imag(dc2); 
_Dcomplex result = {real_part, imag_part}; 
संबंधित मुद्दे