www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - fwrite in DLL

All,

I have a C library that performs an fwrite on an already opened file handle.
When I build and use the library as a DLL I receive an exception.  When I
build and use the library as a static library it works fine.  Using WinDbg
from the Digital Mars D package dmd.2.058.zip shows the exception as being in
__fp_lock.  I have recreated the problem with a small project that is
attached.  I am using the 8.52c C compiler package though dmc.exe says 8.42n.
 I replaced snn.lib with that from the D package to see if it would make a
difference and it did not.  Am I missing something when creating the DLL?  The
rest of my library works great.

Any help will be greatly appreciated!!!

Thank you!
-- Daryl
begin 644 test.tar
M0W1E<W0N8P``````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````#`P,#`T,#``,#`U,#(P-P`P,#(T-#(Q`#`P,#`P,#`Q-#$Q
M`#$Q-S<P-C`Q,#$Q`#`Q,C0T-P` ,```````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````!U<W1A<B` `&1K:C<X
M<P``````````````````````````````````1&]M86EN(%5S97)S````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````C:6YC;'5D92`B37E,:6(N:"(*"B-I9F1E9B!5
M4T5?3$E"4D%260H)(V1E9FEN92!&24Q%7TY!344)(D-S=&%T:6,N='AT( HC
M96QS90H)(V1E9FEN92!&24Q%7TY!344)(D-S:&%R960N='AT( HC96YD:68*
M"B-I9F1E9B!?7T)/4DQ!3D1#7U\*"2-P<F%G;6$ 87)G<W5S960*(V5L:68 
M9&5F:6YE9"A?35-#7U9%4BD*"2-P<F%G;6$ =V%R;FEN9RAD:7-A8FQE.B`T
M,3`P*0HC96YD:68*:6YT(&UA:6XH:6YT(&-O;G-T(&%R9V,L(&-H87( 8V]N
M<W0 *B!C;VYS="!A<F=V6UTI"GL)1DE,12`J:&%N9&QE(#T 9F]P96XH1DE,
M15].04U%+"`B=RLB*3L*" EI9B`H:&%N9&QE("$]("A&24Q%("HI(#`I" E[
M"6-H87( 8V]N<W0 *B!C;VYS="!C;VYT96YT(#T (EQN270 =V]R:V1E9"%<
M;EQN(CL*"0EC:&%R(&-O;6UA;F1;.#!=.PH*"0E'<F5E=&EN9RAH86YD;&4I
M.PH)"69W<FET92AC;VYT96YT+"!S:7IE;V8H8VAA<BDL('-T<FQE;BAC;VYT
M96YT*2P :&%N9&QE*3L*"0EF8VQO<V4H:&%N9&QE*3L*"0EF<')I;G1F*'-T
M9&]U="P (EQN2&5R92!A<F4 =&AE(&-O;G1E;G1S(&]F("5S.EQN7&XB+"!&
M24Q%7TY!344I.PH)"7-T<F-P>2AC;VUM86YD+"`B;6]R92`B*3L*"0ES=')C
M870H8V]M;6%N9"P 1DE,15].04U%*3L*"0ES>7-T96TH8V]M;6%N9"D[" D)
M9G!R:6YT9BAS=&1O=70L(")3;R`E<R!W;W)K961<;EQN(BP 87)G=ELP72D[
M" E]" ER971U<FXH,"D["GT*(VEF9&5F(%]-4T-?5D52" DC<')A9VUA('=A
M<FYI;F<H9&5F875L=#H -#$P,"D*(V5N9&EF" H`````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````1$Q,+F,`````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````#`P,#`T,#``,#`U,#(P-P`P,#(T-#(Q`#`P,#`P
M,#`Q-34Q`#$Q-S<P-3<R-S<T`#`Q,C`S-`` ,```````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````````````!U<W1A<B` 
M`&1K:C<X<P``````````````````````````````````1&]M86EN(%5S97)S
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````````````C:69D968 7TU30U]615(*"2-P<F%G
M;6$ =V%R;FEN9RAD:7-A8FQE.B`T,#`Q*0HC96YD:68*(V1E9FEN92!724XS
M,E],14%.7T%.1%]-14%."B-I;F-L=61E(#QW:6YD;W=S+F ^"B-I9F1E9B!?
M35-#7U9%4 H)(W!R86=M82!W87)N:6YG*&1E9F%U;'0Z(#0P,#$I"B-E;F1I
M9 H*(VEF9&5F(%]?0D]23$%.1$-?7PH)(W!R86=M82!A<F=S=7-E9`HC96QI
M9B!D969I;F5D*%]-4T-?5D52*0H)(W!R86=M82!W87)N:6YG*&1I<V%B;&4Z
M(#0Q,#`I"B-E;F1I9 I?7V1E8VQS<&5C*&1L;&5X<&]R="D 0D]/3"!724Y!
M4$D 1&QL36%I;BA(24Y35$%.0T4 :&%N9&QE+"!$5T]21"!R96%S;VXL($Q0
M5D])1"!R97-E<G9E9"D*>PE"3T],(')E=%9A;"`](%12544[" H)+RH 4&5R
M9F]R;2!A8W1I;VYS(&)A<V5D(&]N('1H92!R96%S;VX 9F]R(&-A;&QI;F<Z
M("HO" ES=VET8V  *')E87-O;BD " E["6-A<V4 1$Q,7U!23T-%4U-?0514
M04-(. H)"0DO*B!);FET:6%L:7IE(&]N8V4 9F]R(&5A8V  ;F5W('!R;V-E
M<W,N("!2971U<FX 1D%,4T4 =&\ 9F%I;"!$3$P ;&]A9"X *B\*"0D)8G)E
M86L[" D)8V%S92!$3$Q?4%)/0T534U]$151!0T Z"0D)+RH 4&5R9F]R;2!A
M;GD ;F5C97-S87)Y(&-L96%N=7`N("HO" D)"6)R96%K.PH)"6-A<V4 1$Q,
M7U1(4D5!1%]!5%1!0T Z"0D)"2\J($1O('1H<F5A9"US<&5C:69I8R!I;FET
M:6%L:7IA=&EO;BX *B\*"0D)8G)E86L[" D)8V%S92!$3$Q?5$A214%$7T1%
M5$%#2#H)"0D)+RH 1&\ =&AR96%D+7-P96-I9FEC(&-L96%N=7`N("HO" D)
M"6)R96%K.PH)?0H)<F5T=7)N*')E=%9A;"D["GT*(VEF9&5F(%]-4T-?5D52
M" DC<')A9VUA('=A<FYI;F<H9&5F875L=#H -#$P,"D*(V5N9&EF" H`````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````1W)E970N8P``````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````#`P,#`T,#``,#`U,#(P-P`P,#(T-#(Q
M`#`P,#`P,#`P-#<T`#$Q-S<P-3<W,34U`#`Q,C0W,`` ,```````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````````````````````!U
M<W1A<B` `&1K:C<X<P``````````````````````````````````1&]M86EN
M(%5S97)S````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````````````````````C:6YC;'5D92`\<W1R:6YG
M+F ^" HC:6YC;'5D92`B37E,:6(N:"(*"FEN="!'<F5E=&EN9RA&24Q%("IO
M=71P=713=')E86TI"GL):6YT(')E=%9A;"`](#`[" H):68 *&]U='!U=%-T
M<F5A;2`]/2`H1DE,12`J*2`P*0H)"65R<FYO(#T 14E.5D%,.PH)96QS90H)
M>PEC:&%R(&-O;G-T("H 8V]N<W0 9W)E971I;F< /2`B2&5L;&\ 8W)U96P 
M=V]R;&0L(CL*" D)<F5T5F%L(#T 9G=R:71E*&=R965T:6YG+"!S:7IE;V8H
M8VAA<BDL('-T<FQE;BAG<F5E=&EN9RDL(&]U='!U=%-T<F5A;2D /B`P(#\ 
M,2`Z(#`[" E]" ER971U<FXH<F5T5F%L*3L*?0H*````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`$UY3&EB+F `````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````P,#`P-#`P`#`P-3`R,#<`,#`R-#0R,0`P,#`P,#`P,3`Q
M- `Q,3<W,#8P,#(Q-0`P,3(T,30`(#``````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````=7-T87( (`!D:VHW
M.',``````````````````````````````````$1O;6%I;B!5<V5R<P``````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````(VEF;F1E9B!-65],24)?2`H)(V1E9FEN92!-
M65],24)?2`H*"2-I;F-L=61E(#QE<G)N;RYH/ H)(VEN8VQU9&4 /'-T9&EO
M+F ^" H)(VEF;F1E9B!%6%!/4T5?344*"0DC:69D968 7U]U;FEX" D)"2-D
M969I;F4 15A03U-%7TU%"65X=&5R; H)"2-E;&EF(&1E9FEN960H7U=)3C,R
M*0H)"0DC:69D968 0E5)3$1?1$Q," D)"0DC9&5F:6YE($584$]315]-10E?
M7V1E8VQS<&5C*&1L;&5X<&]R="D*"0D)(V5L:68 *&1E9FEN960H0E5)3$1?
M3$E"4D%262D ?'P 9&5F:6YE9"A54T5?3$E"4D%262DI" D)"0DC9&5F:6YE
M($584$]315]-10EE>'1E<FX*"0D)(V5L<V4*"0D)"2-D969I;F4 15A03U-%
M7TU%"5]?9&5C;'-P96,H9&QL:6UP;W)T*0H)"0DC96YD:68*"0DC96YD:68*
M"2-E;F1I9 H*"2-I9F1E9B!?7V-P;'5S<&QU<PH)"65X=&5R;B`B0R( >PH)
M(V5N9&EF" H)15A03U-%7TU%(&EN="!'<F5E=&EN9RA&24Q%("IO=71P=713
M=')E86TI.PH*"2-I9F1E9B!?7V-P;'5S<&QU<PH)"7T*"2-E;F1I9 HC96YD
M:68*" ``````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````&=O+F)A=```````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````P,#`P-#`P`#`P-3`R,#<`,#`R-#0R,0`P,#`P
M,#`P-#,Q- `Q,3<W,#8P,C`T,``P,3(S,S``(#``````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````=7-T87( 
M(`!D:VHW.',``````````````````````````````````$1O;6%I;B!5<V5R
M<P``````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````0$5C:&\ ;V9F" I3970 1$U#7TA/
M344]0SI<;W!T7$1I9VET86Q-87)S7# N-3(*4V5T($1-0T,])41-0U](3TU%
M)5QB:6Y<9&UC"E-E="!&3$%'4STM;6X +7<M"E-E="!&3$%'4U]$14)51STM
M0R`M9S1H;"`M4PI3970 24Y#/2U))41-0U](3TU%)5QI;F-L=61E("U)+ I3
M970 3$E"4SUS;FXN;&EB(&ME<FYE;#,R+FQI8B!U<V5R,S(N;&EB(&=D:3,R
M+FQI8B!A9'9A<&DS,BYL:6( =W,R7S,R+FQI8 H*:68 ;F]T(&5X:7-T('-H
M87)E9"!M:V1I<B!S:&%R960*:68 ;F]T(&5X:7-T('-H87)E9"!';W1O(#IF
M86EL"FEF(&YO="!E>&ES="!S=&%T:6, ;6MD:7( <W1A=&EC"FEF(&YO="!E
M>&ES="!S=&%T:6, 1V]T;R`Z9F%I;`H*" IR96T *B`J("H *B`J"G)E;2!"
M=6EL9"!T:&4 1$Q,. IR96T *B`J("H *B`J"B5$34-#)2`M8R`E1DQ!1U,E
M("U$0E5)3$1?1$Q,("5)3D,E($1,3"YC("UO<VAA<F5D7$1,3"YO8FH*:68 
M;F]T(&5X:7-T('-H87)E9%Q$3$PN;V)J($=O=&\ .F9A:6P*"B5$34-#)2`M
M8R`E1DQ!1U,E("5&3$%'4U]$14)51R4 +41"54E,1%]$3$P )4E.0R4 1W)E
M970N8R`M;W-H87)E9%Q'<F5E="YO8FH*:68 ;F]T(&5X:7-T('-H87)E9%Q'
M<F5E="YO8FH 1V]T;R`Z9F%I;`H*<F5M($AO=R!C86X =&AE(&QI;FL <W1A
M=&5M96YT(&)E('-I;&5N8V5D/PHE1$U#0R4 +5=$("5&3$%'4R4 )49,04=3
M7T1%0E5')2!S:&%R961<1$Q,+F]B:B!S:&%R961<1W)E970N;V)J("UO37DN
M9&QL("5,24)3)0II9B!N;W0 97AI<W0 37DN9&QL($=O=&\ .F9A:6P*"B5$
M34-?2$]-125<8FEN7&EM<&QI8B`O;F]I9VYO<F5C87-E("]S>7-T96T 37E)
M;7!O<G0N;&EB($UY+F1L;"`^;G5L"FEF(&YO="!E>&ES="!->4EM<&]R="YL
M:6( 1V]T;R`Z9F%I;`H*" IR96T *B`J("H *B`J"G)E;2!"=6EL9"!T:&4 
M<W1A=&EC(&QI8G)A<GDZ"G)E;2`J("H *B`J("H*)41-0T,E("UC("5&3$%'
M4R4 +41"54E,1%],24)205)9("5)3D,E($=R965T+F, +6]S=&%T:6-<1W)E
M970N;V)J"B5$34-?2$]-125<8FEN7&QI8B`M8R`M;B!->2YL:6( <W1A=&EC
M7$=R965T+F]B: II9B!N;W0 97AI<W0 37DN;&EB($=O=&\ .F9A:6P*" H*
M<F5M("H *B`J("H * IR96T 0G5I;&0 =&AE($, 1$Q,('1E<W0Z"G)E;2`J
M("H *B`J("H*)41-0T,E("5&3$%'4R4 )49,04=37T1%0E5')2`E24Y#)2!#
M=&5S="YC("UO0W-H87)E9"YE>&4 37E);7!O<G0N;&EB"FEF(&YO="!E>&ES
M="!#<VAA<F5D+F5X92!';W1O(#IF86EL" H*"G)E;2`J("H *B`J("H*<F5M
M($)U:6QD('1H92!#('-T871I8R!L:6)R87)Y('1E<W0Z"G)E;2`J("H *B`J
M("H*)41-0T,E("5&3$%'4R4 +4154T5?3$E"4D%262`E24Y#)2!#=&5S="YC
M("UO0W-T871I8RYE>&4 37DN;&EB("5,24)3)0II9B!N;W0 97AI<W0 0W-T
M871I8RYE>&4 1V]T;R`Z9F%I;`H*" IR96T *B`J("H *B`J"G)E;2!2=6X 
M=&AE('1E<W1S. IR96T *B`J("H *B`J"D!%8VAO(%)U;B!T:&4 0R!S=&%T
M:6, ;&EB<F%R>2!T97-T. I#<W1A=&EC"D!%8VAO(%)U;B!T:&4 0R!$3$P 
M=&5S=#H*<F5M($-S:&%R960*)41-0U](3TU%)5QB:6Y<5VEN1&)G($-S:&%R
M960*" H*1V]T;R`Z8VQE86X*" H*.F9A:6P*0$5C:&\Z"D!%8VAO($)U:6QD
M(&9A:6QE9"$*0$5C:&\Z" H*"CIC;&5A; II9B!N;W0 97AI<W0 <VAA<F5D
M($=O=&\ .G-T871I8PII9B!E>&ES="!S:&%R961<*BYO8FH 9&5L("]1('-H
M87)E9%PJ"G)M9&ER('-H87)E9`H*.G-T871I8PII9B!N;W0 97AI<W0 <W1A
M=&EC($=O=&\ .F]T:&5R"FEF(&5X:7-T('-T871I8UPJ+F]B:B!D96P +U$ 
M<W1A=&EC7"H*<FUD:7( <W1A=&EC" HZ;W1H97(*:68 97AI<W0 0W-H87)E
M9"YE>&4 9&5L($-S:&%R960N97AE"FEF(&5X:7-T($-S:&%R960N;6%P(&1E
M;"!#<VAA<F5D+FUA<`II9B!E>&ES="!#<VAA<F5D+G1X="!D96P 0W-H87)E
M9"YT>'0*:68 97AI<W0 0W-T871I8RYE>&4 9&5L($-S=&%T:6,N97AE"FEF
M(&5X:7-T($-S=&%T:6,N;6%P(&1E;"!#<W1A=&EC+FUA<`II9B!E>&ES="!#
M<W1A=&EC+G1X="!D96P 0W-T871I8RYT>'0*:68 97AI<W0 0W1E<W0N;V)J
M(&1E;"!#=&5S="YO8FH*:68 97AI<W0 37DN9&5F(&1E;"!->2YD968*:68 
M97AI<W0 37DN9&QL(&1E;"!->2YD;&P*:68 97AI<W0 37DN;&EB(&1E;"!-
M>2YL:6(*:68 97AI<W0 37DN;6%P(&1E;"!->2YM87`*:68 97AI<W0 37E)
M;7!O<G0N;&EB(&1E;"!->4EM<&]R="YL:6(*" ``````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
9````````````````````````````````````
`
end
Jun 21 2012