We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have a function,but the compiler terminated because the function is too complex.
C51 FATAL-ERROR - ACTION: GENERATING INTERMEDIATE CODE ERROR: FUNCTION '_siParseDescriptor' (LINE 1058, T=400,L=132,l=1): TOO COMPLEX C51 TERMINATED.
Take a look at Andy's Handy Hint for Debugging Preprocessor Problems: http://www.8052.com/forum/read.phtml?id=29152 Note that the preprocessor listing is itself a 'C' source file - so you can get the compiler to compile it. This might pinpoint the error a bit more closely?
I suspect the problem is just the complexity of that huge, huge, expression. When you introduce the intermediate variables, you simply the amount of code in one chunk, which I imagine is why the code starts to compile. What's the purpose of the "do {} while(0)" in your create macro? Simple curly braces should work as well to introduce a local block. Also, just as a readability and style nitpick, complicated macros are probably better defined using the backslash to allow them to occupy multiple lines.
#define CreateSatelliteDeliverySystemDescriptor(descr, freq, orb, mod, polar, sr, fec) { xCreateNode (((struct SatelliteDeliverySystemDescriptor *)descr), NULL); ((struct SatelliteDeliverySystemDescriptor *)descr)->Tag = DESCR_SAT_DEL_SYS; ((struct SatelliteDeliverySystemDescriptor *)descr)->Frequency = freq; ((struct SatelliteDeliverySystemDescriptor *)descr)->OrbitalPosition = orb; ((struct SatelliteDeliverySystemDescriptor *)descr)->Modulation = mod; ((struct SatelliteDeliverySystemDescriptor *)descr)->Polarization = polar; ((struct SatelliteDeliverySystemDescriptor *)descr)->SymbolRate = sr; ((struct SatelliteDeliverySystemDescriptor *)descr)->FEC = fec; }
too comples to compile how about "too complex to rtead" Why does "real C" programmers insist on cramming more than a human can understand into a single statement. As far as I can see this can easiy be broken up in 4-10 understandable statements. Is there really a reason to make it as tough as posssible on the next guy/gal assigned maintenance of the code? Erik
"What's the purpose of the "do {} while(0)" in your create macro? Simple curly braces should work as well to introduce a local block." Not quite. Consider the use of a function-like macro (i.e., terminated with a semicolon) in an if/else clause expanding to the curly brace from only. Please refer to: http://www.eskimo.com/~scs/C-faq/q10.4.html The do/while(0) method is the safe way to define a function-like (multi-statement) macro.